adrian0605
Programmer
Hi,
I'm trying to get a value from a dropdownlist(ddl1) to use as a parameter in another dropdownlist(ddl2), in same editable datalist.
<edititempemplate>
<aspropDownList id="ddl1" runat="server">
<asp:ListItem Text="xxxxxx" Value="1" />
</aspropDownList>
<aspropDownList id="ddl2" runat="server" datavaluefield="LoID" datatextfield="LoID" DataSource="<%# TempDataView2 %>" />
</editimtemplate>
Code behind:
Private Sub dlClient_EditCommand(...)
PopulateDropDownList2()
dlInfogen.EditItemIndex = e.Item.ItemIndex
getClients()
End Sub
Sub PopulateDropDownList2()
Dim TempList2 As DropDonwlist = CType(FindControl("ddl1"), DropDownList)
Dim Temval as string = TempList2.SelectedItem.Value
Dim dataAdapter2 As SqlDataAdapter
dataAdapter2 = New SqlDataAdapter("GetLoc", objConn)
dataAdapter2.SelectCommand.CommandType = CommandType.StoredProcedure
dataAdapter2.SelectCommand.Parameters.Add("@JID", SqlDbType.Int).Value = Temval
dataAdapter2.Fill(objDS, "Loc")
TempDataView2 = objDS.Tables("Loc").DefaultView
End Sub
My problem is that I get an error "Object reference not set to an instance of an object.".
Semms that I can't get the value from ddl1, using FindControl.
Can somebody tell me where I'm wrong?
I'm trying to get a value from a dropdownlist(ddl1) to use as a parameter in another dropdownlist(ddl2), in same editable datalist.
<edititempemplate>
<aspropDownList id="ddl1" runat="server">
<asp:ListItem Text="xxxxxx" Value="1" />
</aspropDownList>
<aspropDownList id="ddl2" runat="server" datavaluefield="LoID" datatextfield="LoID" DataSource="<%# TempDataView2 %>" />
</editimtemplate>
Code behind:
Private Sub dlClient_EditCommand(...)
PopulateDropDownList2()
dlInfogen.EditItemIndex = e.Item.ItemIndex
getClients()
End Sub
Sub PopulateDropDownList2()
Dim TempList2 As DropDonwlist = CType(FindControl("ddl1"), DropDownList)
Dim Temval as string = TempList2.SelectedItem.Value
Dim dataAdapter2 As SqlDataAdapter
dataAdapter2 = New SqlDataAdapter("GetLoc", objConn)
dataAdapter2.SelectCommand.CommandType = CommandType.StoredProcedure
dataAdapter2.SelectCommand.Parameters.Add("@JID", SqlDbType.Int).Value = Temval
dataAdapter2.Fill(objDS, "Loc")
TempDataView2 = objDS.Tables("Loc").DefaultView
End Sub
My problem is that I get an error "Object reference not set to an instance of an object.".
Semms that I can't get the value from ddl1, using FindControl.
Can somebody tell me where I'm wrong?