T
Terry Olsen
I've got a datagrid set up to display data. I've also got an
Edit,Update,Cancel column set up to allow editing of data.
I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain
column that I need to populate while in Edit Mode.
Two questions: Is there a way to directly use another DropDownList as a
DataSource? If so how?
I'm using the following code to try to populate the DropDownList, but
getting an "Object Reference not set to an Instance of an Object" error
when trying to add items to it. The column is the 4th column (index=3).
If I remove the code after the "LoadGrid()" line, then everything
populates fine except for the DropDownList, which is empty.
Hopefully someone can help me get this code working.
-----------------------------------------
Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.EditCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
btnAddServer.Visible = False
LoadGrid()
Dim ddl As DropDownList =
CType(e.Item.Cells(3).FindControl("ddl3"), DropDownList)
For i As Integer = 0 To ddlTechs.Items.Count - 1
ddl.Items.Add(ddlTechs.Items.Item(i).Value)
Next
End Sub
Edit,Update,Cancel column set up to allow editing of data.
I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain
column that I need to populate while in Edit Mode.
Two questions: Is there a way to directly use another DropDownList as a
DataSource? If so how?
I'm using the following code to try to populate the DropDownList, but
getting an "Object Reference not set to an Instance of an Object" error
when trying to add items to it. The column is the 4th column (index=3).
If I remove the code after the "LoadGrid()" line, then everything
populates fine except for the DropDownList, which is empty.
Hopefully someone can help me get this code working.
-----------------------------------------
Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.EditCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
btnAddServer.Visible = False
LoadGrid()
Dim ddl As DropDownList =
CType(e.Item.Cells(3).FindControl("ddl3"), DropDownList)
For i As Integer = 0 To ddlTechs.Items.Count - 1
ddl.Items.Add(ddlTechs.Items.Item(i).Value)
Next
End Sub