By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,771 Members | 1,858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,771 IT Pros & Developers. It's quick & easy.

RadioButtonList: Show selected

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a

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 discussion thread is closed

Replies have been disabled for this discussion.