473,396 Members | 1,995 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,396 software developers and data experts.

Add radio button dynamically at run-time

Hi all,

I'm reading user information from Active Directory. I'm allowing the users to search by username from a web form. There will be times when the result will be more than one record. What I'm trying to do is to generate radio buttons at run-time, so users can select the user account they are looking for, and then populate the information into a form.

My question is how do I create a single event handler for more than one radio button, so I can write the code to populate the information in the form controls.

here is the portion of the code where I want to create the radio buttons:
Any help is greatly appreciated

foreach (SearchResult result in search.FindAll())
{
if (result.Properties["samAccountName"].Count > 0 && result.Properties["mail"].Count > 0 && result.Properties["givenname"].Count > 0 && result.Properties["sn"].Count > 0)
{
Response.Write("<tr><td>" + result.Properties["samAccountName"][0].ToString() + "</td><td>" + result.Properties["mail"][0].ToString() + "</td><td>" + result.Properties["givenname"][0].ToString() + "</td><td>" + result.Properties["sn"][0].ToString() + "</td></tr>");
}
}
May 28 '08 #1
1 7404
Curtis Rutland
3,256 Expert 2GB
What you need to use is the RadioButtonList. That way, you tie the event handler to the list, and adding items is simple.

Expand|Select|Wrap|Line Numbers
  1. <!-- On the .aspx page -->
  2. <asp:RadioButtonList ID="rbl1" runat="server">
  3.     <asp:ListItem Text="One" Value="1"></asp:ListItem>
  4. </asp:RadioButtonList>
  5. <asp:Button ID="b1" runat="server" Text="Add Radio Button" OnClick="cmd" />
Expand|Select|Wrap|Line Numbers
  1. //on the .aspx.cs page
  2. protected void cmd(object sender, EventArgs e)
  3. {
  4.     rbl1.Items.Add(new ListItem("another", "2"));
  5. }
  6.  
So every time you click the button, you add a RadioButton to the RadioButtonList.
May 28 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: David | last post by:
Hi, May I know how to create data dynamically in a combo box after clicking on a radio button ? Data are retrieved using a store procedure from a SQL Server. For example : Click Radio Button...
6
by: Craig Keightley | last post by:
I have a page that has n number of radio groups (yes/No) how can i prevent the form being submitted if more than one radio group is not selected? By default all radio groups are unchecked ...
2
by: Rob | last post by:
Hi all, I've got multiple sets of radio button that are dynamically created in code and populated by a database query. The query returns about 20 recordsets with 3 radio buttons per recordset and...
1
by: Jerry | last post by:
We have a 10-question quiz for kids, each question being a yes or no answer using radio selections. I'd like to keep a current total of yes's and no's at the bottom of the quiz (if the user selects...
5
by: sam | last post by:
Hi all, I am dynamically creating a table rows and inerting radio buttons which are also dynamically created. Everything works fine in Firefox as expected. But I am not able to select radio...
7
by: nathaniel.k.lee | last post by:
Is it not possible, in IE, to dynamically click a radio button? I'm grabbing some values from a database and using them to populate radio buttons on a page. I have alternate code for Firefox...
1
by: truptidalia | last post by:
Hello, I am trying to add 2 RadioButtons in a form in js dynamically. I can see 2 radiobutttons, but no text. On clicking them, their is no selection. One of them is selected. I need to...
7
by: moksha | last post by:
Hi, I am new to javascript and i am facing a problem in coding. plz help me out. I am using javascript for dynamically creating a table row which contains text boxes and radio...
5
by: Gotejjeken | last post by:
I have a form with four radio buttons and I want to store the value of the selected radio button (it's a poll and need to capture and record the user's response). I'm dynamically generating...
1
by: ramel | last post by:
Hi all, I have a problem related to javascript , ajax and jsp. Please see this url http://xil.co.in/print_screen_2.JPG. I am working on this form. There are some buttons (like submit ,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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
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,...

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.