Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting a value from a dropdownlist in a editable datalist

Status
Not open for further replies.

adrian0605

Programmer
Apr 3, 2007
10
RO
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>

<asp:DropDownList id="ddl1" runat="server">
<asp:ListItem Text="xxxxxx" Value="1" />
</asp:DropDownList>


<asp:DropDownList 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?

 
Your question might be answered more quickly if you post here:
forum855

The VB.Net forum gets more Windows Forms activity over Web Forms.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top