Ask a Question related to ASP.NET General, Design and Development.
-
John Criswell #1
Programmatically Selecting Item in Radio Button List
I have created a radio button list programmatically.
C#
SqlConnection conn = new SqlConnection("data source=localhost;
integrated security=true; initial catalog=pubs");
SqlCommand cmdAuthors = new SqlCommand("select * from Authors", conn);
SqlDataReader dr;
dr = cmdAuthors.ExecuteReader();
RadioButtonList rblAuthors = new RadioButtonList();
rblAuthors.DataSource = dr;
rblAuthors.DataTextField = "au_fname" + " " + "au_lname";
rblAuthors.DataBind();
dr.Close();
conn.Close();
The first item in the radio button list should be "Johnson White" as
he is the first author in the authors table of the pubs database. He
is the first author because the index on the table is on SSN and he
has the lowest SSN.
Now I want to programmatically "select" the radio button associated
with the listitem that corresonds to "Johnson White." I don't want
the user to make that selection; I want the application to do it on a
page load for example. How do I write the code to "select" or "check"
a radio button item in a radio button itemlist programmatically?
Any help or suggestions will be greatly appreciated.
Thanks,
John Criswell
John Criswell Guest
-
Radio Button & List to search - ASP
Hi Guys, Can someone point me to a tutorial for DW 8 or advise me on how to do this. I want to search a database using 2 radio buttons and a... -
How to put a full radio button list in each row of datagrid?
Hello, I have a datagrid where I display images. I want visitors to be able to rate the images on a scale of 1 to 10 by clicking a radio button,... -
radio button list doesn't hold value?
Hi. I have a radio button list with list items assigned via a datareader from a database. Everything looks fine, the items are there on page load,... -
how to make columns the same size in a radio button list
The only thing i can figure out is making the length of the Text property on each listitem the same. That means something like this: ... -
Radio Button List server control and java script
How can i check in java script if a asp.net radio button list server control is selected? I have some custom javascript function in the client... -
John Criswell #2
Re: Programmatically Selecting Item in Radio Button List
Ray,
Your code worked perfectly and did exactly what I wanted it to do. You
said that you had some difficulties with my code. I apologize for that.
I didn't test it to see if it would work. I just put down some sample
code using the famous "pubs" database to communicate my concept. I'm
sorry if my code caused you some difficulties.
On the bright side, I plugged your method into my project, and it worked
the first time. You are an outstanding C# ASP.NET programmer.
Many thanks,
John Criswell
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
John Criswell Guest



Reply With Quote

