Hi!
i just don't know how to do this. can anyone help me, please.
i'm trying to populate dropdownlist which is in datalist. Data should come from sql database. Here is the dropdownlist:
VB Code:
<asp:DropDownList ID="dropList" Runat="server" DataTextField="place_name" DataValueField="place_id"></asp:DropDownList>
and here is what i have tried:
VB Code:
Sub BindData(ByVal intCompany_id As Integer) Dim sqlConnStr As String = ConfigurationSettings.AppSettings("ConnectionString") Dim sqlConn As New SqlConnection(sqlConnStr) Dim sqlSelect As String = "SELECT * FROM Places WHERE place_company_id=" & intCompany_id Dim sqlCmd As SqlCommand sqlConn.Open() Dim sqlDR As SqlDataReader sqlCmd = New SqlCommand(sqlSelect, sqlConn) sqlDR = sqlCmd.ExecuteReader() While sqlDR.Read() Dim newListItem As New ListItem newListItem.Text = sqlDR.Item("place_name") newListItem.Value = sqlDR.Item("place_id") dropList.Items.Add(newListItem) End While sqlConn.Close() End Sub
I don't know how to catch the right dropdownlist object in datalist to populate. any ideas? anyone?
Thanks in advance
- Minna![]()




Reply With Quote