Issues in generating radiobuttonlist from MSSQL..

G

Guest

i wanted to generate a radiobuttonlist, that lists items from MSSQL query.

Like the table had

DPRT_ID DPRT_NAME
1 HR
2 IT
3 ADMIN

Here the vb code…

Dim conPubs As SqlConnection
Dim cmdSelect As SqlCommand
Dim mydata As DataSet
conPubs = New SqlConnection("server=XXX;Database=XXX;uid=sa;password=;")
cmdSelect = New SqlCommand("select * from tbl_Departments", conPubs)

conPubs.Open()
radiobuttonlist1.DataSource = cmdSelect.ExecuteReader()
radiobuttonlist1.DataBind()
conPubs.Close()

when I run this I don’t see anything in my aspx page..

help me…
 
C

Christopher Reed

Before the radiobuttonlist1.DataBind(), add these lines:

radiobuttonlist1.DataTextField = "DPRT_NAME"
radiobuttonlist1.DataValueField = "DPRT_ID"
 
G

Guest

thx it worked...

Christopher Reed said:
Before the radiobuttonlist1.DataBind(), add these lines:

radiobuttonlist1.DataTextField = "DPRT_NAME"
radiobuttonlist1.DataValueField = "DPRT_ID"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top