Hello all,
I have ddlA that loads another ddlB on a postback. I AM Able to get ddlA to load in the page load event;however, i can not get the ddlB to load from the selected value from ddlA.
Can someone please help me with this.
* I am very much open to all solutions for this issue. IF YOU have a better way or an easier way of doing this, by all means, please share it with me!
Erik.
'
'GO NOW!
'
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Customers()
End If
End Sub
'
Private Sub Customers()
ddlCustomers.DataSource = GetData()
ddlCustomers.DataTextField = "CompanyName"
ddlCustomers.DataValueField = "CompanyName"
ddlCustomers.DataBind()
End Sub
'
Private Sub LoadList()
ddlCompanyName.Items.Clear()
ddlCompanyName.DataSource = GetData(ddlCustomers.SelectedValue).CompanyName 'ado.net query
ddlCompanyName.DataBind()
End Sub
'''''
'...Northwind
''''
Function GetData()
'
Dim cnn As New SqlConnection("data source= desktop; initial catalog= northwind; trusted_Connection=yes")
'
Dim cmd As New SqlCommand("SELECT * FROM Customers", cnn)
cmd.CommandType = CommandType.Text
'
cnn.Open()
Dim result As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Return result
cnn.Close()
result.Close()
End Function
'
End Class 'STOOOOOOOOP!...
===============================================Drop Downs.................
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 136px; WIDTH: 504px; POSITION: absolute; TOP: 88px; HEIGHT: 167px"
cellSpacing="1" cellPadding="1" width="504" border="1">
<TR>
<TD style="HEIGHT: 85px"></TD>
<TD style="WIDTH: 183px; HEIGHT: 85px"></TD>
<TD style="HEIGHT: 85px"><asp:dropdownlist id="ddlCompanyName" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
</TR>
<TR>
<TD style="HEIGHT: 24px"></TD>
<TD style="WIDTH: 183px; HEIGHT: 24px">Company Name</TD>
</TD></TR>
<TR>
<TD></TD>
<TD style="WIDTH: 183px">Customers</TD>
<TD><asp:dropdownlist id="ddlCustomers" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
</TR>
</TABLE>
</form>
</body>