Problem in selecting Radio Button inside Repeater Control

selector-button.png

Incase we are using RadioButton inside a Repeater, one common problem which we face is that we are not able to select single RadioButton, i.e. If we select one RadioButton, and then click on the other the other also gets selected without unselecting the first one.
Even the GroupName property of the RadioButton dosen’t works for this.

The solution I got is:

1. Set the AutoPostBack property of the RadioButton to “true”.
2. Make OnCheckedChanged event for the RadioButton.

Example:

  1. <asp:RadioButton ID=”rbtnSelectEmp” runat=”server” AutoPostBack=”true”
  2. OnCheckedChanged=”rbtnSelectEmp_OnCheckedChanged” />

3. Inside OnCheckedChanged event write the following code:

  1. protected void rbtnSelectEmp_OnCheckedChanged(object sender, EventArgs e)
  2. {
  3. foreach (RepeaterItem item in rptEmployee.Items)
  4. {
  5. RadioButton rbtn = (RadioButton)item.FindControl(“rbtnSelectEmp”);

Read full blog at our highly specific C, android,iphone, Javascript,HTML, PHP developer forum about the topic described above Problem in selecting Radio Button inside Repeater Control . You can also learn much more about different programming technologies and can enhance your tech skills.

Advertisements
Problem in selecting Radio Button inside Repeater Control

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s