473,327 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

RadioButtonList: Show selected

I'm making a page to update articles.
When a radiobuttonlist is displayed, I want the stored value to be displayed
as default (checked).

Example: I use a procedure to display the RadioButtonList. An input to this
procedure is the ID that is stored in the database. I want the
radiobuttonlist to show the radiobutton with datavaluefield = savedID as
checked when it is displayed.
Private Sub getTypes(ByVal savedID)
Dim conn As New SqlConnection(variables.ConnString)
Dim cmd As New SqlCommand("spShowType", conn)
cmd.CommandType = CommandType.StoredProcedure

cmd.Connection.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Me.radTypeList.DataSource = dr
Me.radTypeList.DataTextField = "content"
Me.radTypeList.DataValueField = "typeID"
'Me.radTypeList.SelectedIndex = savedID

Me.radTypeList.DataBind()
cmd.Connection.Close()
cmd.Dispose()
conn.Dispose()
End Sub
I have tried this:
"Me.radTypeList.SelectedIndex = savedID" does not work.
"Me.radTypeList.SelectedItem = savedID" does not work either.
Thanks for all tips!!!
Feb 20 '06 #1
5 6967
Hi

I believe radTypeList is name of your RadioButtonList control,
use
radTypeList .SelectedValue =savedID.toString()

e.g

ASP.Net page

<body >
<form id="form1" runat="server" >
<div>

<br />

<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
</asp:RadioButtonList>
</form>
</body>

Code behind page (c#)
protected void Page_Load(object sender, EventArgs e)

{

RadioButtonList1.SelectedValue = "2";

}
Hope this will solve your problem..

Vinu



"Øyvind Isaksen" <oyvind@

webressurs.no> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I'm making a page to update articles.
When a radiobuttonlist is displayed, I want the stored value to be
displayed as default (checked).

Example: I use a procedure to display the RadioButtonList. An input to
this procedure is the ID that is stored in the database. I want the
radiobuttonlist to show the radiobutton with datavaluefield = savedID as
checked when it is displayed.
Private Sub getTypes(ByVal savedID)
Dim conn As New SqlConnection(variables.ConnString)
Dim cmd As New SqlCommand("spShowType", conn)
cmd.CommandType = CommandType.StoredProcedure

cmd.Connection.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Me.radTypeList.DataSource = dr
Me.radTypeList.DataTextField = "content"
Me.radTypeList.DataValueField = "typeID"
'Me.radTypeList.SelectedIndex = savedID

Me.radTypeList.DataBind()
cmd.Connection.Close()
cmd.Dispose()
conn.Dispose()
End Sub
I have tried this:
"Me.radTypeList.SelectedIndex = savedID" does not work.
"Me.radTypeList.SelectedItem = savedID" does not work either.
Thanks for all tips!!!

Feb 20 '06 #2
Hello!

I get the errormessage "Selectedvalue is not a member of
System.Web.UI.WebControls.RadioButtonList" when I try that...
I only have the choices of using "SelectedIndex" or "SelectedItem", there is
no "SelectedValue" on the radiobuttonlist-control.

Strange!?


"vinu" <vi*********@googlemail.com> wrote in message
news:u$**************@tk2msftngp13.phx.gbl...
Hi

I believe radTypeList is name of your RadioButtonList control,
use
radTypeList .SelectedValue =savedID.toString()

e.g

ASP.Net page

<body >
<form id="form1" runat="server" >
<div>

<br />

<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
</asp:RadioButtonList>
</form>
</body>

Code behind page (c#)
protected void Page_Load(object sender, EventArgs e)

{

RadioButtonList1.SelectedValue = "2";

}
Hope this will solve your problem..

Vinu



"Øyvind Isaksen" <oyvind@

webressurs.no> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I'm making a page to update articles.
When a radiobuttonlist is displayed, I want the stored value to be
displayed as default (checked).

Example: I use a procedure to display the RadioButtonList. An input to
this procedure is the ID that is stored in the database. I want the
radiobuttonlist to show the radiobutton with datavaluefield = savedID as
checked when it is displayed.
Private Sub getTypes(ByVal savedID)
Dim conn As New SqlConnection(variables.ConnString)
Dim cmd As New SqlCommand("spShowType", conn)
cmd.CommandType = CommandType.StoredProcedure

cmd.Connection.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Me.radTypeList.DataSource = dr
Me.radTypeList.DataTextField = "content"
Me.radTypeList.DataValueField = "typeID"
'Me.radTypeList.SelectedIndex = savedID

Me.radTypeList.DataBind()
cmd.Connection.Close()
cmd.Dispose()
conn.Dispose()
End Sub
I have tried this:
"Me.radTypeList.SelectedIndex = savedID" does not work.
"Me.radTypeList.SelectedItem = savedID" does not work either.
Thanks for all tips!!!


Feb 20 '06 #3
Hi,
Yes, there is a property called SelectedValue

check this site
http://msdn.microsoft.com/library/de...mberstopic.asp
vinu

"Øyvind Isaksen" <oy****@webressurs.no> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
Hello!

I get the errormessage "Selectedvalue is not a member of
System.Web.UI.WebControls.RadioButtonList" when I try that...
I only have the choices of using "SelectedIndex" or "SelectedItem", there
is no "SelectedValue" on the radiobuttonlist-control.

Strange!?


"vinu" <vi*********@googlemail.com> wrote in message
news:u$**************@tk2msftngp13.phx.gbl...
Hi

I believe radTypeList is name of your RadioButtonList control,
use
radTypeList .SelectedValue =savedID.toString()

e.g

ASP.Net page

<body >
<form id="form1" runat="server" >
<div>

<br />

<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
</asp:RadioButtonList>
</form>
</body>

Code behind page (c#)
protected void Page_Load(object sender, EventArgs e)

{

RadioButtonList1.SelectedValue = "2";

}
Hope this will solve your problem..

Vinu



"Øyvind Isaksen" <oyvind@

webressurs.no> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I'm making a page to update articles.
When a radiobuttonlist is displayed, I want the stored value to be
displayed as default (checked).

Example: I use a procedure to display the RadioButtonList. An input to
this procedure is the ID that is stored in the database. I want the
radiobuttonlist to show the radiobutton with datavaluefield = savedID as
checked when it is displayed.
Private Sub getTypes(ByVal savedID)
Dim conn As New SqlConnection(variables.ConnString)
Dim cmd As New SqlCommand("spShowType", conn)
cmd.CommandType = CommandType.StoredProcedure

cmd.Connection.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Me.radTypeList.DataSource = dr
Me.radTypeList.DataTextField = "content"
Me.radTypeList.DataValueField = "typeID"
'Me.radTypeList.SelectedIndex = savedID

Me.radTypeList.DataBind()
cmd.Connection.Close()
cmd.Dispose()
conn.Dispose()
End Sub
I have tried this:
"Me.radTypeList.SelectedIndex = savedID" does not work.
"Me.radTypeList.SelectedItem = savedID" does not work either.
Thanks for all tips!!!



Feb 20 '06 #4
Hello,

It seems like it has to do with the framework version I use...
I run Visual Studio .Net with framework 1.0 (1.0.3705). I have updated now
Visual Studio with all new service releases, and installed Framework v.1.1
on my computer. But still it seems like visual studio uses framevork 1.0.

Framework 1.0 dont support the "SelectedValue" Property (RadioButtonList
control).
In the Microsoft documentation Microsoft writes: "Note: This namespace,
class, or member is supported only in version 1.1 of the .NET Framework."

Do you know how to fix this??


"vinu" <vi*********@googlemail.com> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
Hi,
Yes, there is a property called SelectedValue

check this site
http://msdn.microsoft.com/library/de...mberstopic.asp
vinu

"Øyvind Isaksen" <oy****@webressurs.no> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
Hello!

I get the errormessage "Selectedvalue is not a member of
System.Web.UI.WebControls.RadioButtonList" when I try that...
I only have the choices of using "SelectedIndex" or "SelectedItem", there
is no "SelectedValue" on the radiobuttonlist-control.

Strange!?


"vinu" <vi*********@googlemail.com> wrote in message
news:u$**************@tk2msftngp13.phx.gbl...
Hi

I believe radTypeList is name of your RadioButtonList control,
use
radTypeList .SelectedValue =savedID.toString()

e.g

ASP.Net page

<body >
<form id="form1" runat="server" >
<div>

<br />

<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
</asp:RadioButtonList>
</form>
</body>

Code behind page (c#)
protected void Page_Load(object sender, EventArgs e)

{

RadioButtonList1.SelectedValue = "2";

}
Hope this will solve your problem..

Vinu



"Øyvind Isaksen" <oyvind@

webressurs.no> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I'm making a page to update articles.
When a radiobuttonlist is displayed, I want the stored value to be
displayed as default (checked).

Example: I use a procedure to display the RadioButtonList. An input to
this procedure is the ID that is stored in the database. I want the
radiobuttonlist to show the radiobutton with datavaluefield = savedID
as checked when it is displayed.
Private Sub getTypes(ByVal savedID)
Dim conn As New SqlConnection(variables.ConnString)
Dim cmd As New SqlCommand("spShowType", conn)
cmd.CommandType = CommandType.StoredProcedure

cmd.Connection.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Me.radTypeList.DataSource = dr
Me.radTypeList.DataTextField = "content"
Me.radTypeList.DataValueField = "typeID"
'Me.radTypeList.SelectedIndex = savedID

Me.radTypeList.DataBind()
cmd.Connection.Close()
cmd.Dispose()
conn.Dispose()
End Sub
I have tried this:
"Me.radTypeList.SelectedIndex = savedID" does not work.
"Me.radTypeList.SelectedItem = savedID" does not work either.
Thanks for all tips!!!



Feb 21 '06 #5

HI
Why to 1.1, upgrade to 2.0

see the following lik

http://msdn.microsoft.com/asp.net/re...ojectsvs05.asp

http://searchvb.techtarget.com/vsnet...293033,00.html

Vinu
"Øyvind Isaksen" <oy****@webressurs.no> wrote in message
news:ec*************@TK2MSFTNGP09.phx.gbl...
Hello,

It seems like it has to do with the framework version I use...
I run Visual Studio .Net with framework 1.0 (1.0.3705). I have updated
now Visual Studio with all new service releases, and installed Framework
v.1.1 on my computer. But still it seems like visual studio uses framevork
1.0.

Framework 1.0 dont support the "SelectedValue" Property (RadioButtonList
control).
In the Microsoft documentation Microsoft writes: "Note: This namespace,
class, or member is supported only in version 1.1 of the .NET Framework."

Do you know how to fix this??


"vinu" <vi*********@googlemail.com> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
Hi,
Yes, there is a property called SelectedValue

check this site
http://msdn.microsoft.com/library/de...mberstopic.asp
vinu

"Øyvind Isaksen" <oy****@webressurs.no> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
Hello!

I get the errormessage "Selectedvalue is not a member of
System.Web.UI.WebControls.RadioButtonList" when I try that...
I only have the choices of using "SelectedIndex" or "SelectedItem",
there is no "SelectedValue" on the radiobuttonlist-control.

Strange!?


"vinu" <vi*********@googlemail.com> wrote in message
news:u$**************@tk2msftngp13.phx.gbl...
Hi

I believe radTypeList is name of your RadioButtonList control,
use
radTypeList .SelectedValue =savedID.toString()

e.g

ASP.Net page

<body >
<form id="form1" runat="server" >
<div>

<br />

<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
</asp:RadioButtonList>
</form>
</body>

Code behind page (c#)
protected void Page_Load(object sender, EventArgs e)

{

RadioButtonList1.SelectedValue = "2";

}
Hope this will solve your problem..

Vinu



"Øyvind Isaksen" <oyvind@

webressurs.no> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
> I'm making a page to update articles.
> When a radiobuttonlist is displayed, I want the stored value to be
> displayed as default (checked).
>
> Example: I use a procedure to display the RadioButtonList. An input to
> this procedure is the ID that is stored in the database. I want the
> radiobuttonlist to show the radiobutton with datavaluefield = savedID
> as checked when it is displayed.
>
>
> Private Sub getTypes(ByVal savedID)
> Dim conn As New SqlConnection(variables.ConnString)
> Dim cmd As New SqlCommand("spShowType", conn)
> cmd.CommandType = CommandType.StoredProcedure
>
> cmd.Connection.Open()
> Dim dr As SqlDataReader = cmd.ExecuteReader
> Me.radTypeList.DataSource = dr
> Me.radTypeList.DataTextField = "content"
> Me.radTypeList.DataValueField = "typeID"
> 'Me.radTypeList.SelectedIndex = savedID
>
> Me.radTypeList.DataBind()
> cmd.Connection.Close()
> cmd.Dispose()
> conn.Dispose()
> End Sub
>
>
> I have tried this:
> "Me.radTypeList.SelectedIndex = savedID" does not work.
> "Me.radTypeList.SelectedItem = savedID" does not work either.
>
>
> Thanks for all tips!!!
>



Feb 21 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: juststarter | last post by:
Hello, I have an aspx file where i've put a placeholder element. On load i create dynamically a table which contains a checkbox and a radiobuttonlist in each tablerow . The radiobuttonlist...
3
by: William LaMartin | last post by:
If I create a RadioButtonList with, say, two items, then after the page loads and I select one of the items and then click on a button whose click event contains some code to display the...
5
by: DotNetGruven | last post by:
Anyone have any pointers on how to set the Value and Selected attributes in a ListItem in a RadioButtonList that is in a DataGrid? Here's what I have ------DataGrid------ -- BoundColumn 0 --...
1
by: msn | last post by:
I am trying to update my database with the code below, but I have a problem it neither buton is selected??? <asp:radiobuttonlist id="BDec1" runat="server" RepeatDirection="Horizontal"...
4
by: Emil | last post by:
Can somebody tell me what would be the syntax for having an if statement and setting the selected index of a radiobuttonlist? This is my first project using ASP.net and I use C#. I have a repeater...
3
by: Mark Broadbent | last post by:
try as I might (and using different properties) this control always seems to be returning the first element of the control as the "selected" item even though I am selecting the second element. All...
4
by: juststarter | last post by:
Hello, I have an aspx file where i've put a placeholder element. On load (page_load) i create dynamically an html table which contains a checkbox and a radiobuttonlist in each tablerow . The...
2
by: Michael Bohman | last post by:
Hi, i have a small problem with assigning a database value to a RadioButtonList control. On my form i have 3 user admin=1, premium=2 and basic=3, theese values is stored in an access database in a...
6
by: SAL | last post by:
hello, I'm using a radiobuttonlist in an updatepanel in an item template in a Gridview control. I'm populating the radiobuttonlist in the RowDataBound event. I have the control toolkit registered...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.