473,320 Members | 2,189 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Dynamic RadioButton IDs - help

Hi,
I have a RadioButton within a Repeater that i wish to assign an ID
dynamically to the radiobutton. However, this won't allow me due to the
following error:
"'<%#((OnlineLearningEnvironment.MultipleChoiceCho ice)Container.DataItem).choiceText%>'
is not a valid identifier."

So, my question is, what do I do? (Code follows)

Thank you in advance,

Tim.

<asp:Repeater ID="repeaterChoices" Runat="server">
<HeaderTemplate>
<blockquote>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:RadioButton
ID="<%#((Choice)Container.DataItem).choiceID%>"
Text="<%#((Choice)Container.DataItem).choiceText%> "
Runat="server"></asp:RadioButton></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</blockquote>
</FooterTemplate>
</asp:Repeater>
<FooterTemplate>
</table>
</blockquote>
</FooterTemplate>
</asp:Repeater>
Nov 18 '05 #1
2 2923
You can not assign dynamically ID's to the radiobutons like this
you can try this

<asp:Repeater ID="repeaterChoices" Runat="server">
<HeaderTemplate>
<blockquote>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:RadioButton
ID="rbChoice"
Text="<%#((Choice)Container.DataItem).choiceText%> "
Runat="server"></asp:RadioButton><
<asp:Label id="lblChoice"
Text="<%#((Choice)Container.DataItem).choiceID%>" Visible="False"
Runat="server" />
/td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</blockquote>
</FooterTemplate>
</asp:Repeater>
<FooterTemplate>
</table>
</blockquote>
</FooterTemplate>
</asp:Repeater>

when you want to check the id, just check the contents of the label's text
property for the curent e.Item

Hope this helps

Regards
Martin

"Timothy V" <tr****@msn.com> wrote in message
news:#A*************@tk2msftngp13.phx.gbl...
Hi,
I have a RadioButton within a Repeater that i wish to assign an ID
dynamically to the radiobutton. However, this won't allow me due to the
following error:
"'<%#((OnlineLearningEnvironment.MultipleChoiceCho ice)Container.DataItem).ch
oiceText%>' is not a valid identifier."

So, my question is, what do I do? (Code follows)

Thank you in advance,

Tim.

<asp:Repeater ID="repeaterChoices" Runat="server">
<HeaderTemplate>
<blockquote>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:RadioButton
ID="<%#((Choice)Container.DataItem).choiceID%>"
Text="<%#((Choice)Container.DataItem).choiceText%> "
Runat="server"></asp:RadioButton></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</blockquote>
</FooterTemplate>
</asp:Repeater>
<FooterTemplate>
</table>
</blockquote>
</FooterTemplate>
</asp:Repeater>

Nov 18 '05 #2
try this:
DataBinder.Eval(Container.DataItem,Choice.ChoiceId )

I'm not sure, because I seldom use Collection to populate data, Hope it
will help.
Hi,
I have a RadioButton within a Repeater that i wish to assign an ID
dynamically to the radiobutton. However, this won't allow me due to the
following error:
"'<%#((OnlineLearningEnvironment.MultipleChoiceCho ice)Container.DataItem).ch
oiceText%>' is not a valid identifier."

So, my question is, what do I do? (Code follows)

Thank you in advance,

Tim.

<asp:Repeater ID="repeaterChoices" Runat="server">
<HeaderTemplate>
<blockquote>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:RadioButton
ID="<%#((Choice)Container.DataItem).choiceID%>"
Text="<%#((Choice)Container.DataItem).choiceText%> "
Runat="server"></asp:RadioButton></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</blockquote>
</FooterTemplate>
</asp:Repeater>
<FooterTemplate>
</table>
</blockquote>
</FooterTemplate>
</asp:Repeater>

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: VK | last post by:
Hi! What I'm missing in following code? Cannot get the values of radiobuttons. Starting only one class (GetVariant), it works. When I put two classes together, it doesn't. Regards, VK from...
3
by: sofie | last post by:
Hello all, I use the following javascript function in a html document to set the level of one of eight available radiobuttons. The line that's commented out works fine under IE, but I need to...
1
by: Mick | last post by:
Hi, Dynamically adding Checkbox and GroupRadioButton (extended control http://www.codeproject.com/aspnet/groupradiobuttons.asp) to placeholder. In fact, displaying questions and answers. When...
5
by: Mike Salter | last post by:
I created a page that reads a DB for questions and possible answers (usuallyYes/No). I create a panel for each group of questions, and add a panel for each question to the Group panel. To the...
5
by: Matt Jensen | last post by:
Am I right in saying that you can't have a Radiobutton web control inside a repeater bound to a database datasource and (inline) dynamically set it's ID and text properties from the repeaters rows?...
0
by: Wagner Garcia Campagner | last post by:
Hello, I'm trying to create dynamic RadioButton as follows: for i in out.keys(): msg = "radioButton_" + str(i) msg2 = 20 * x msg = QRadioButton(self.buttonGroup_interfaces, msg)...
0
by: chxant | last post by:
Hi, I'm trying to develop a webapplication with a dynamic panel. The first time the PanelResult is empty. After the user clicked on the Login button I want to show a couple of radiobuttons...
1
by: bungle | last post by:
Hi, I want to generate a questionnaire from questions held in SQL Server on my windows application. The format will always be the same - a question and then four radio buttons with values 1...
12
by: ive1122 | last post by:
Hi guys, I am looking into create a dynamic survey as posted in Get User Input From Dynamic Controls but with some different environment Below is what i am trying to do: First when the user...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.