I have an Unsubscribe page(Unsubscribe.aspx) that generates three radio buttons and a text field by using a repeater.
The id's of the radio buttons come from databinding and I need to get those ID's to use in the code page but I can't seem to get it to recognize the existence of this binding.
Unsubscribe.aspx looks like this:
<asp:Repeater ID="rptReasons" runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<div>
<div class="col-lg-12">
<label class="radio-custom">
<input id='rbReason<%# DataBinder.Eval(Container, "DataItem.ID")%>' type="radio" name="rbReason" value='<%# DataBinder.Eval(Container, "DataItem.ID")%>'>
<i class="fa fa-circle-o"></i>
<label for='rbReason<%# DataBinder.Eval(Container, "DataItem.ID")%>'><%# DataBinder.Eval(Container, "DataItem.Explanation")%></label>
</label>
<%# (DataBinder.Eval(Container.DataItem, "ReasonType").ToString() == "OTH") ? "<input class='form-control m-t m-l-n-md' name='txtComment' type='text' maxlength='100' style='width:300px;' />" : "" %>
</div>
</div>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
And this is the behaviour I want to achieve:
if (DataItem.ID == checked )
{
disable the text area
}
try to add
runat="server"
<input runat="server" id='rbReason<%# DataBinder.Eval(Container, "DataItem.ID")%>' type="radio" name="rbReason" value='<%# DataBinder.Eval(Container, "DataItem.ID")%>'>
after that you need to find control on event
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
Label lbl = (Label)e.Item.FindControl("Label1");
LinkButton link = (LinkButton)e.Item.FindControl("LinkButton1");
RadioButton rdbtn = (RadioButton)e.Item.FindControl("control_id");
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.