Hi,
I'm trying to setup a datagrid which is databound, but when editing a particular column, rather than a text box, the options are displayed in a dropdown list. I'm setting up the datagrid as shown below.
The problem I have is getting a link to the dropdown list in the edit template column.Code:<asp:DataGrid id="grdSPs" runat="server"> <Columns> <asp:BoundColumn DataField="SP_Name"</asp:BoundColumn> <asp:BoundColumn DataField="SP_Cnt"></asp:BoundColumn> <asp:TemplateColumn> <ItemTemplate> <%# Container.DataItem("TT_Name") %> </ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="cmbEditT" runat="server"> </asp:DropDownList> </EditItemTemplate> </asp:TemplateColumn> <asp:EditCommandColumn ButtonType="LinkButton" EditText="Edit"> </asp:EditCommandColumn> </Columns> </asp:DataGrid>
The code behind I've tried is...
I'm thinking that maybe the dropdown list control isn't actually created during the EditCommand routine. Any help would be much appreciated.Code:Private Sub grdSPs_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grdSPs.EditCommand grdSPs.EditItemIndex = e.Item.ItemIndex SetupEditTable() 'This calls a routine to bind the datagrid and is working fine. 'Call routine to retrieve dataset using stored procedure 'This is working fine, the Table is created fine in the dataset Dim TDataSet As DataSet = GetDataSet("GetTerritories", EF, "TTable") 'Now I'm trying to get a link to the dropdown list Dim cmbTList As System.Web.UI.WebControls.DropDownList cmbTList = e.Item.FindControl("cmbEditT") 'This always returns NOTHING 'Once I can get the above reference to work, I should be OK End Sub
Thanks.




Reply With Quote