Read Value from DropDownList in TemplateColumn?

  • Thread starter Vagabond Software
  • Start date
V

Vagabond Software

I am fairly new to ASP.NET, so bear with me...

I have a Datagrid with a data-bound DropDownList in the TemplateColumn. Here
is the HTML code:

<asp:TemplateColumn HeaderText="Void">
<ItemStyle horizontalalign="Left" wrap="False"></ItemStyle>
<ItemTemplate>
<%#Databinder.Eval(Container.DataItem, "isVoid")%>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlIsVoid" Runat="server"
CssClass="ddl100"></asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>

In Edit Mode, the end-user can select either True or False in the
DropDownList, then save those changes. ALL of that is working correctly.

The trouble comes when I try to deal with the value of that Datagrid column
directly. It appears to always equate to String.Empty. Everytime the
Datagrid is displayed, I go through the rows and change the Row forecolor to
Red where the IsVoid column is True.

Private Sub ColorVoidRows(ByVal dg As DataGrid, ByVal vindex As Integer)

For Each item As DataGridItem In dg.Items
If item.Cells(vindex).Text = "True" Then
item.ForeColor = Color.Red
End If
Next
End Sub

This method works on a number of other Datagrid that can be displayed on the
page, but those Datagrids don't have the templated IsVoid column. So, I
figure it must have something to do with that.

The Cells index is working and I have confirmed that I am looking at the
correct column.

My question is how do I retrieve that value from that TemplateColumn when I
am NOT in Edit Mode?

Any help is greatly appreciated.

carl
 

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,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top