When I run this code I get:
Object reference not set to an instance of an object.
It's referring to the line of:
ddlTitle1.DataSource = DS
Here's the code:
Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.EditCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
'Build the DDL For the Title section
Con1.Open()
Dim strDDL As String
strDDL = "SELECT DISTINCT Title FROM Employees ORDER BY Title"
Dim da As New OleDb.OleDbDataAdapter()
da.SelectCommand = New OleDb.OleDbCommand(strDDL, Con1)
Dim DS As New DataSet()
da.Fill(DS)
Dim ddlTitle1 As DropDownList = e.Item.FindControl("ddlTitle")
ddlTitle1.DataSource = DS
ddlTitle1.DataMember = "Employees"
ddlTitle1.DataTextField = "Title"
ddlTitle1.DataValueField = "Title"
ddlTitle1.DataBind()
Con1.Close()
Object reference not set to an instance of an object.
It's referring to the line of:
ddlTitle1.DataSource = DS
Here's the code:
Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.EditCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
'Build the DDL For the Title section
Con1.Open()
Dim strDDL As String
strDDL = "SELECT DISTINCT Title FROM Employees ORDER BY Title"
Dim da As New OleDb.OleDbDataAdapter()
da.SelectCommand = New OleDb.OleDbCommand(strDDL, Con1)
Dim DS As New DataSet()
da.Fill(DS)
Dim ddlTitle1 As DropDownList = e.Item.FindControl("ddlTitle")
ddlTitle1.DataSource = DS
ddlTitle1.DataMember = "Employees"
ddlTitle1.DataTextField = "Title"
ddlTitle1.DataValueField = "Title"
ddlTitle1.DataBind()
Con1.Close()