Having problems populating a gridview field in my codebehind RowDataBound - and having it available to Edit in the gridview.
Here is the field definition in the GridView:<asp:TemplateField HeaderText="Oversight" SortExpression="LVL_ACCESS_ID">
<ItemTemplate>
<asp:Label ID="LvlAccId" runat="server" Text='' Font-Size="Small"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<aspropDownList ID="ddOvrs" runat="server" DataSourceID="LUWOvrsList"
DataTextField="LVL_ACCESS_ID" DataValueField="LVL_ACCESS_ID"
SelectedValue='<%# Bind("LVL_ACCESS_ID") %>' Font-Size="Small">
</aspropDownList>
</EditItemTemplate>
<FooterTemplate>
<aspropDownList ID="ddOvrs" runat="server" DataSourceID="LUWOvrsList"
DataTextField="LVL_ACCESS_ID" DataValueField="LVL_ACCESS_ID"
SelectedValue='<%# Bind("LVL_ACCESS_ID") %>' Font-Size="Small">
</aspropDownList>
</FooterTemplate>
</asp:TemplateField>
I am building the Item field to display in my code behind RowDataBound routine as follows:
Based on another column value – I look up some data in a table – and format a display of data into cell(5) of my gridview.
Public Sub gvCustGrps_BuildRow(ByVal sender As Object, ByVal e As GridViewRowEventArgs) _Handles gvCustGrps.RowDataBound
Dim rCust As String = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "ACCS_CUSTDN_NAM")).Trim()If (rCust > "") Then Dim rowOvrs As String = Get_Group_Oversight(rowCust) If (rowOvrs > "") Then e.Row.Cells(5).Text = rowOvrs End If Some rows will not have data to display in cell(5).
Gridview seems to display okay first time in. But the problem is when the user clicks a row Edit button.
Several fields on the row are dropdown boxes like this one.
But for some reason this field does not open up in Edit mode and provide the dropdown box you see above in the EditItemTemplete.
Is there something I need to do in this RowDataBound routine to make the field available to Edit so that it recognizes the dropdown parms in the EditItemTemplate? (FooterTemplate works fine.)
Thanks
Here is the field definition in the GridView:<asp:TemplateField HeaderText="Oversight" SortExpression="LVL_ACCESS_ID">
<ItemTemplate>
<asp:Label ID="LvlAccId" runat="server" Text='' Font-Size="Small"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<aspropDownList ID="ddOvrs" runat="server" DataSourceID="LUWOvrsList"
DataTextField="LVL_ACCESS_ID" DataValueField="LVL_ACCESS_ID"
SelectedValue='<%# Bind("LVL_ACCESS_ID") %>' Font-Size="Small">
</aspropDownList>
</EditItemTemplate>
<FooterTemplate>
<aspropDownList ID="ddOvrs" runat="server" DataSourceID="LUWOvrsList"
DataTextField="LVL_ACCESS_ID" DataValueField="LVL_ACCESS_ID"
SelectedValue='<%# Bind("LVL_ACCESS_ID") %>' Font-Size="Small">
</aspropDownList>
</FooterTemplate>
</asp:TemplateField>
I am building the Item field to display in my code behind RowDataBound routine as follows:
Based on another column value – I look up some data in a table – and format a display of data into cell(5) of my gridview.
Public Sub gvCustGrps_BuildRow(ByVal sender As Object, ByVal e As GridViewRowEventArgs) _Handles gvCustGrps.RowDataBound
Dim rCust As String = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "ACCS_CUSTDN_NAM")).Trim()If (rCust > "") Then Dim rowOvrs As String = Get_Group_Oversight(rowCust) If (rowOvrs > "") Then e.Row.Cells(5).Text = rowOvrs End If Some rows will not have data to display in cell(5).
Gridview seems to display okay first time in. But the problem is when the user clicks a row Edit button.
Several fields on the row are dropdown boxes like this one.
But for some reason this field does not open up in Edit mode and provide the dropdown box you see above in the EditItemTemplete.
Is there something I need to do in this RowDataBound routine to make the field available to Edit so that it recognizes the dropdown parms in the EditItemTemplate? (FooterTemplate works fine.)
Thanks