problem with radiobutton list control

A

Ankit Aneja

code of my aspx page

<asp:RadioButtonList id="RadioButtonList1"
runat="server"></asp:RadioButtonList>

now i want to bind data from database
Dim rsComm As SqlCommand

Dim rsReader As SqlDataReader

Dim strSql As String

Dim con As SqlConnection

con = New SqlConnection("server=abc;UID=sa;PWD=sa;initial
catalog=digicertify")

con.Open()

strSql = "select certName from certDetail"

rsComm = New SqlCommand(strSql, con)

rsReader = rsComm.ExecuteReader

rsReader = rsReader

RadioButtonList1.DataSource = rsReader

RadioButtonList1.DataBind()

rsReader.Close()

rsComm.Dispose()

con.Close()



it makes radio buttons as no. of items selected but instead of displaying
certName as selected in query it displays

System.Data.Common.DbDataRecord
System.Data.Common.DbDataRecord
System.Data.Common.DbDataRecord
System.Data.Common.DbDataRecord
System.Data.Common.DbDataRecord
System.Data.Common.DbDataRecord
System.Data.Common.DbDataRecord
System.Data.Common.DbDataRecord
System.Data.Common.DbDataRecord
System.Data.Common.DbDataRecord

in front of each radio button
 
S

Steven Cheng[MSFT]

Thanks for Eliyahu's input,

Hi Ankit,

As Eliyahu has mentioned, we can use the RadioButtonList.DataTextField and
DataValueField to specify which field from the DataSource Item we want to
bind. So in your scenario, there exist the "certName" column from the
database records, we can specify the RadioButtonList.DataTextField as the
"certName" so that the certName column's value will be bind as the
RadiobutotnList's item's display value, (and it's the same for
DataValueField...)

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
--------------------
| From: "Eliyahu Goldin" <[email protected]>
| References: <[email protected]>
| Subject: Re: problem with radiobutton list control
| Date: Thu, 6 Oct 2005 09:33:35 +0200
| Lines: 64
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 212.143.94.2
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:129371
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| RadioButtonList1.DataTextField="certName"
|
| Eliyahu
|
| | > code of my aspx page
| >
| > <asp:RadioButtonList id="RadioButtonList1"
| > runat="server"></asp:RadioButtonList>
| >
| > now i want to bind data from database
| > Dim rsComm As SqlCommand
| >
| > Dim rsReader As SqlDataReader
| >
| > Dim strSql As String
| >
| > Dim con As SqlConnection
| >
| > con = New SqlConnection("server=abc;UID=sa;PWD=sa;initial
| > catalog=digicertify")
| >
| > con.Open()
| >
| > strSql = "select certName from certDetail"
| >
| > rsComm = New SqlCommand(strSql, con)
| >
| > rsReader = rsComm.ExecuteReader
| >
| > rsReader = rsReader
| >
| > RadioButtonList1.DataSource = rsReader
| >
| > RadioButtonList1.DataBind()
| >
| > rsReader.Close()
| >
| > rsComm.Dispose()
| >
| > con.Close()
| >
| >
| >
| > it makes radio buttons as no. of items selected but instead of
displaying
| > certName as selected in query it displays
| >
| > System.Data.Common.DbDataRecord
| > System.Data.Common.DbDataRecord
| > System.Data.Common.DbDataRecord
| > System.Data.Common.DbDataRecord
| > System.Data.Common.DbDataRecord
| > System.Data.Common.DbDataRecord
| > System.Data.Common.DbDataRecord
| > System.Data.Common.DbDataRecord
| > System.Data.Common.DbDataRecord
| > System.Data.Common.DbDataRecord
| >
| > in front of each radio button
| >
| >
|
|
|
 
S

Steven Cheng[MSFT]

Good. Glad that you've got it working.

Have a nice day!

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
--------------------
| From: "Ankit Aneja" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: problem with radiobutton list control
| Date: Thu, 6 Oct 2005 18:50:53 +0530
| Lines: 109
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: dsl-upwest-static-039.7.246.61.touchtelindia.net
61.246.7.39
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:129446
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| thanks Steven
| i was able to do it after Eliyahu's reply
| | > Thanks for Eliyahu's input,
| >
| > Hi Ankit,
| >
| > As Eliyahu has mentioned, we can use the RadioButtonList.DataTextField
and
| > DataValueField to specify which field from the DataSource Item we want
to
| > bind. So in your scenario, there exist the "certName" column from the
| > database records, we can specify the RadioButtonList.DataTextField as
the
| > "certName" so that the certName column's value will be bind as the
| > RadiobutotnList's item's display value, (and it's the same for
| > DataValueField...)
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > --------------------
| > | From: "Eliyahu Goldin" <[email protected]>
| > | References: <[email protected]>
| > | Subject: Re: problem with radiobutton list control
| > | Date: Thu, 6 Oct 2005 09:33:35 +0200
| > | Lines: 64
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
| > | Message-ID: <[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: 212.143.94.2
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:129371
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | RadioButtonList1.DataTextField="certName"
| > |
| > | Eliyahu
| > |
| > | | > | > code of my aspx page
| > | >
| > | > <asp:RadioButtonList id="RadioButtonList1"
| > | > runat="server"></asp:RadioButtonList>
| > | >
| > | > now i want to bind data from database
| > | > Dim rsComm As SqlCommand
| > | >
| > | > Dim rsReader As SqlDataReader
| > | >
| > | > Dim strSql As String
| > | >
| > | > Dim con As SqlConnection
| > | >
| > | > con = New SqlConnection("server=abc;UID=sa;PWD=sa;initial
| > | > catalog=digicertify")
| > | >
| > | > con.Open()
| > | >
| > | > strSql = "select certName from certDetail"
| > | >
| > | > rsComm = New SqlCommand(strSql, con)
| > | >
| > | > rsReader = rsComm.ExecuteReader
| > | >
| > | > rsReader = rsReader
| > | >
| > | > RadioButtonList1.DataSource = rsReader
| > | >
| > | > RadioButtonList1.DataBind()
| > | >
| > | > rsReader.Close()
| > | >
| > | > rsComm.Dispose()
| > | >
| > | > con.Close()
| > | >
| > | >
| > | >
| > | > it makes radio buttons as no. of items selected but instead of
| > displaying
| > | > certName as selected in query it displays
| > | >
| > | > System.Data.Common.DbDataRecord
| > | > System.Data.Common.DbDataRecord
| > | > System.Data.Common.DbDataRecord
| > | > System.Data.Common.DbDataRecord
| > | > System.Data.Common.DbDataRecord
| > | > System.Data.Common.DbDataRecord
| > | > System.Data.Common.DbDataRecord
| > | > System.Data.Common.DbDataRecord
| > | > System.Data.Common.DbDataRecord
| > | > System.Data.Common.DbDataRecord
| > | >
| > | > in front of each radio button
| > | >
| > | >
| > |
| > |
| > |
| >
|
|
|
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top