473,503 Members | 9,887 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Having trouble with a RadioButtonList control

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 I need it the index number to
reference a particular row num of a dataset. I only just noticed this today
but it if I cant determine the selected radiobuttonlist item then it reders
this control useless.

Hope someone can help?

--
Br,

Mark Broadbent

Mark Broadbent

mcad, mcdba , mcse+i
Nov 19 '05 #1
3 1401
Post your code please. I think you simply have a delcaration problem.
"Mark Broadbent" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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 I need it the index
number to reference a particular row num of a dataset. I only just noticed
this today but it if I cant determine the selected radiobuttonlist item
then it reders this control useless.

Hope someone can help?

--
Br,

Mark Broadbent

Mark Broadbent

mcad, mcdba , mcse+i

Nov 19 '05 #2
protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1;

/*This bit is from the page load event which dynamically builds each button
for each row*/

foreach (System.Data.DataRow r in dsTalks1.Tables[0].Rows)

{//Do not want to show the video id in dataset so start index at 1

sb.Append("Talk ID:" + r.ItemArray[1].ToString() + ", ");

sb.Append(r.ItemArray[2].ToString() + ", ");

sb.Append(r.ItemArray[3].ToString() + ", ");

sb.Append(r.ItemArray[4].ToString());
this.RadioButtonList1.Items.Add(sb.ToString());

this.RadioButtonList1.Items[0].Selected = true;

//Clear string builder for next cycle

sb.Remove(0, sb.Length);}

/*And this bit is from my button click event handler which should find the
selected radiobutton - but always returns the first item*/

while (this.RadioButtonList1.Items[talkselected].Selected != true)

{talkselected ++;}

//Change videoid in the dataset

System.Data.DataRow row = this.dsTalks1.Tables[0].Rows[talkselected];

"Mark Sandfox" <No****@NoSpam.com> wrote in message
news:kK****************@newssvr31.news.prodigy.com ...
Post your code please. I think you simply have a delcaration problem.
"Mark Broadbent" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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 I need it the index
number to reference a particular row num of a dataset. I only just
noticed this today but it if I cant determine the selected
radiobuttonlist item then it reders this control useless.

Hope someone can help?

--
Br,

Mark Broadbent

Mark Broadbent

mcad, mcdba , mcse+i


Nov 19 '05 #3
Check for ispostback property in pageload before setting radiobuttonlist
selected property otherwise when the button clicked postback fires, it will
set the selectedindex to first row.

--
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com

"Mark Broadbent" <no****@nospam.com> wrote in message
news:uP**************@TK2MSFTNGP09.phx.gbl...
protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1;

/*This bit is from the page load event which dynamically builds each button for each row*/

foreach (System.Data.DataRow r in dsTalks1.Tables[0].Rows)

{//Do not want to show the video id in dataset so start index at 1

sb.Append("Talk ID:" + r.ItemArray[1].ToString() + ", ");

sb.Append(r.ItemArray[2].ToString() + ", ");

sb.Append(r.ItemArray[3].ToString() + ", ");

sb.Append(r.ItemArray[4].ToString());
this.RadioButtonList1.Items.Add(sb.ToString());

this.RadioButtonList1.Items[0].Selected = true;

//Clear string builder for next cycle

sb.Remove(0, sb.Length);}

/*And this bit is from my button click event handler which should find the
selected radiobutton - but always returns the first item*/

while (this.RadioButtonList1.Items[talkselected].Selected != true)

{talkselected ++;}

//Change videoid in the dataset

System.Data.DataRow row = this.dsTalks1.Tables[0].Rows[talkselected];

"Mark Sandfox" <No****@NoSpam.com> wrote in message
news:kK****************@newssvr31.news.prodigy.com ...
Post your code please. I think you simply have a delcaration problem.
"Mark Broadbent" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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 I need it the index
number to reference a particular row num of a dataset. I only just
noticed this today but it if I cant determine the selected
radiobuttonlist item then it reders this control useless.

Hope someone can help?

--
Br,

Mark Broadbent

Mark Broadbent

mcad, mcdba , mcse+i



Nov 19 '05 #4

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

Similar topics

2
8508
by: Mike S | last post by:
I am trying to use a RadioButtonList bound to a custom datasource to acomplish some user functionality. I want to add various onmouseover/onmouseout/onblur/onfocus events to each individual...
6
7705
by: DotNetGruven | last post by:
I have a webform that has a DataGrid on it with a RadioButtonList in each row. It is a simple On & Off. When the User Clicks on either of the RadioButtons, I need to postback to the server and...
5
6974
by: Řyvind Isaksen | last post by:
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...
2
4718
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...
0
2030
by: Sudheer Aalla | last post by:
Hi, When I try to reference the radiobuttonlist control in edititemtemplate in ItemDataBound event of datalist control I am getting NULL reference. I am trying to pre select the yes/no button...
5
2681
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hallo, I have a radiobuttonlist control that is added on a custom Web User Control. This control has a property that exposes the SelectedIndex property of the embedded radiobuttonlist. When...
0
1419
by: =?Utf-8?B?QW5keSBpbiBTb3V0aCBKZXJzZXk=?= | last post by:
I want to use a RadioButtonList Control(HTML) in a GridView control. I can see the RadioButtonList control with each row in the GridView with the code: <asp:GridView ID="GridView1"...
6
2627
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...
13
10697
by: tommymo | last post by:
Hi everyone I'm new to this site and the world of ASP.Net C# programming. I have been learning controls and integrating them with a SQL database. So far I have been able to move along and understand...
0
7095
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7294
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7361
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5602
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3183
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.