Need Help With Datagrid Template Column and Drop Down List Box

B

Benign Vanilla

I am a .NET newbie, and need some help.

I have a datagrid that is bound to a table. That works. I also have a
template column in the grid for updating a status value for each row. This
is defined as:

<asp:TemplateColumn HeaderText="New Order Status">
<ItemTemplate>
<asp:DropDownList Font-Names="Arial" Font-Size="XX-Small"
id="drpOrderStatus"
runat="server" AutoPostBack="true"
OnSelectedIndexChanged="drpOrderStatus_SelectedIndexChanged"
Width="165">
<asp:ListItem Value="0">New</asp:ListItem>
<asp:ListItem Value="1000">Loan Approved</asp:ListItem>
<asp:ListItem Value="1001">Loan Approved With
Gurantee</asp:ListItem>
<asp:ListItem Value="1002">Loan Declined</asp:ListItem>
<asp:ListItem Value="1003">Loan Requires More
Information</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>

In the click event of a button, Save button, I want to loop through my grid
and check the value of each drop box. I have not been able to get this to
work. In this event, I can put a watch on:

dgrdResults.items(i).cells(0).controls(1)

And I can see the drop down list box, but:

dgrdResults.items(i).cells(0).controls(1).SelectedValue

doesn't work. Any thoughts?

BV.
 
T

Tod Birdsall

Hi Benign,

You need to convert the control to a dropdownlist. Try something like
the following.

DropDownList ddl =
(DropDownList)dgrdResults.items(i).cells(0).controls(1)
string myValue = ddl.SelectedValue
Hope this helps.

Tod Birdsall, MCP
http://tod1d.blogspot.com
 
B

Benign Vanilla

Tod Birdsall said:
Hi Benign,

You need to convert the control to a dropdownlist. Try something like
the following.

DropDownList ddl =
(DropDownList)dgrdResults.items(i).cells(0).controls(1)
string myValue = ddl.SelectedValue
Hope this helps.

Tod Birdsall, MCP
http://tod1d.blogspot.com

Tod! Thanks! That was EXACTLY what I needed. Would you be able to point me
to some documentation that exlains the reason and purpose behind this? I'd
like to know what I just did.

BV.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top