Assign ID to a radiobutton inside a checkbox

  • Thread starter Abhishek Srivastava
  • 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.
 
T

Tommy

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top