Katya85S
Programmer
- Jul 19, 2004
- 190
DropdownList and radiobuttonList are populated from sql server, using DataBinding.
Somewhat neither of them shows the value of the first record. For example, if SQL query result is <John, Mike, Kim>, the radiobutton list will have just 2 radiobuttons:
-Mike
-Kim
And the same with DropDownList.
Here is the code for my radiobuttonlist:
aspx code:
<asp:radiobuttonlist id="rbList" runat="server" DataTextField="EmpName" DataValueField="EmpName"></asp:radiobuttonlist>
aspx.vb code:
strSQL = "SELECT EmpName FROM tblEmp WHERE Status = 'm'
myConn.Open()
Dim objCmd As New SqlCommand(strSQL, myConn)
Dim DR As SqlDataReader
DR = objCmd.ExecuteReader(CommandBehavior.CloseConnection)
If DR.Read Then
rbList.DataSource = DR
rbList.DataBind()
End If
objCmd.Dispose()
myConn.Close()
strSQL = ""
Any advice on how to fix this? Thank you all in advance.
Somewhat neither of them shows the value of the first record. For example, if SQL query result is <John, Mike, Kim>, the radiobutton list will have just 2 radiobuttons:
-Mike
-Kim
And the same with DropDownList.
Here is the code for my radiobuttonlist:
aspx code:
<asp:radiobuttonlist id="rbList" runat="server" DataTextField="EmpName" DataValueField="EmpName"></asp:radiobuttonlist>
aspx.vb code:
strSQL = "SELECT EmpName FROM tblEmp WHERE Status = 'm'
myConn.Open()
Dim objCmd As New SqlCommand(strSQL, myConn)
Dim DR As SqlDataReader
DR = objCmd.ExecuteReader(CommandBehavior.CloseConnection)
If DR.Read Then
rbList.DataSource = DR
rbList.DataBind()
End If
objCmd.Dispose()
myConn.Close()
strSQL = ""
Any advice on how to fix this? Thank you all in advance.