Using sqlCmd As New SqlCommand()
sqlCmd.CommandText = "SELECT dept FROM Department"
sqlCmd.Connection = sqlConn
sqlConn.Open()
Dim da As New SqlDataAdapter(sqlCmd)
Dim dt As New DataTable()
According to the code you provided, you seem to have queried data from the database and bound the data source to the drop-down list control. What does your issue mean? Is the value displayed by the drop-down option different from the record in the database?
Or something else?
And I'm not sure if its options have been modified elsewhere in the program. If possible, could you describe the issue you encountered and the results you expect more clearly?
Best regards,
Xudong Peng
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
22 Points
82 Posts
Dropdownlist & to &
Sep 18, 2020 08:23 PM|kafsar|LINK
I have database field value: "kma & awx"
in Dropdownlist popup show "kma & ; awx"
<asp:DropDownList ID="EmpDept" runat="server" Height="27px" Width="296px" Font-Size="Medium">
<asp:ListItem Value="0">- Please Select</asp:ListItem></asp:DropDownList>
vb.net code:
Using sqlCmd As New SqlCommand()
sqlCmd.CommandText = "SELECT dept FROM Department"
sqlCmd.Connection = sqlConn
sqlConn.Open()
Dim da As New SqlDataAdapter(sqlCmd)
Dim dt As New DataTable()
da.Fill(dt)
EmpDept.DataSource = dt
EmpDept.DataTextField = "dept "
EmpDept.DataValueField = "dept "
EmpDept.DataBind()
sqlConn.Close()
how to solve this issue
Contributor
2110 Points
674 Posts
Re: Dropdownlist & to &
Sep 21, 2020 05:43 AM|XuDong Peng|LINK
Hi kafsar,
According to the code you provided, you seem to have queried data from the database and bound the data source to the drop-down list control. What does your issue mean? Is the value displayed by the drop-down option different from the record in the database? Or something else?
And I'm not sure if its options have been modified elsewhere in the program. If possible, could you describe the issue you encountered and the results you expect more clearly?
Best regards,
Xudong Peng