Home All Groups Group Topic Archive Search About

Issues in generating radiobuttonlist from MSSQL..

Author
22 Feb 2006 2:37 AM
velu
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…

Author
22 Feb 2006 5:19 AM
Christopher Reed
Before the radiobuttonlist1.DataBind(), add these lines:

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

--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

Show quote
"velu" <v***@discussions.microsoft.com> wrote in message
news:8C723F71-4D70-489E-A4C9-4730FE29F493@microsoft.com...
>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.
Author
22 Feb 2006 6:23 AM
velu
thx it worked...

Show quote
"Christopher Reed" wrote:

> Before the radiobuttonlist1.DataBind(), add these lines:
>
> radiobuttonlist1.DataTextField = "DPRT_NAME"
> radiobuttonlist1.DataValueField = "DPRT_ID"
>
> --
> Christopher A. Reed
> "The oxen are slow, but the earth is patient."
>
> "velu" <v***@discussions.microsoft.com> wrote in message
> news:8C723F71-4D70-489E-A4C9-4730FE29F493@microsoft.com...
> >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.
>
>
>

AddThis Social Bookmark Button