Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How can i accessed check value of radio button used in repeater. [using asp.net and C#],
Data is populated from sql server database.

<asp:Repeater ID="rptProfession" runat="server" >
<itemtemplate>

<%# DataBinder.Eval(Container, "DataItem.DescE")%>
<%# DataBinder.Eval(Container, "DataItem.DescA")%>
<asp:RadioButton id="rdbUser" runat="server" OnClick="javascript:SelectSingleRadiobutton(this.id)" />


C# Code Behind Button:
public void Submit_Evaluation(Object s, EventArgs e)
{
foreach (RepeaterItem item in rptProfession.Items)
{
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
{

RadioButton rb = (RadioButton) item.FindControl("rdbUser");
if (rb.Checked)
{
pbadErrorMessage = "Good";
}
if (!rb.Checked)
{
pbadErrorMessage = "Bad";
}
}
}
Posted
Updated 9-Feb-15 22:26pm
v4
Comments
Kornfeld Eliyahu Peter 10-Feb-15 2:15am    
See if this can help you: http://www.codeproject.com/Articles/775111/Understanding-ASP-NET-Templates
What have you tried?

You should use - RepeaterItem.FindControl Method[^].

First find out the RepeaterItem, then use FindControl by passing the Control ID.
 
Share this answer
 
Comments
Masood H. Virk 10-Feb-15 7:25am    
Just Putting DataBind code in the Page_Init procedure, that way the state of the radiobuttons will be set by the time it reaches the Page_Load procedure.
and Set AutoPostBack="true" of Radio Button.

Its work fine....
Just Putting DataBind code in the Page_Init procedure, that way the state of the radiobuttons will be set by the time it reaches the Page_Load procedure.
and Set AutoPostBack="true" of Radio Button.

Its work fine....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900