Read Value from DropDownList in TemplateColumn?

VagabondSW

Regular
Joined
Feb 19, 2005
Messages
66
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:
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.
Visual Basic:
    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.
 
Back
Top