Assign ID to a radiobutton inside a checkbox

  • Thread starter Thread starter Abhishek Srivastava
  • Start date Start date
A

Abhishek Srivastava

Hello All,

I have bound an ArrayList to a repeater control. When the list is
displayed, I want the the user to be able to choose one of the items in
the list and then continue working. To achieve this I have done the
following

<asp:Repeater id='rep1' runat='server'>
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:RadioButton Text='' Runat='server' Group='mygrp'
ID='<%# DataBinder.Eval(Container.DataItem, "Id")%>' />
</td>
<td>
<%#DataBinder.Eval(Container.DataItem, "Name")%>>
</td>
<tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

But I get an error that <%#DataBinder.Eval(Container.DataItem, "ID")%>
is not a valid identifier.

Why can't I assign the ID dynamically?

Thanks for your help in advance.

regards,
Abhishek.
 
You cannot dynamically set the ID of an ASP.NET control in an .aspx
file. Try to create the control dynamically and set the ID in the
code-behind.

For example, handle the OnItemDataBound event, and dynamically create
a radio button web control, set the ID property, and insert the
control to the Repeater.

Tommy,
 
Back
Top