By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,837 Members | 1,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,837 IT Pros & Developers. It's quick & easy.

Radiobutton inside repeater with dynamic ID and text

P: n/a
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?
This is the impression I've got after extensive searching and trial and
error, even thought I have to say I find it hard to believe?
Thanks
Matt
Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Matt,

You may be able to dynamically set the radiobutton's id but i dont think it
would be very useful to you.

If you use the same id in the template, then by the INamingContainer
interface that the repeater implements, the ids will be unique on the client
side (if accessing them from script) and you can still find the control by
myRepeaterItem.FindControl("myradiobuttonid")

HTH jd

"Matt Jensen" wrote:
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?
This is the impression I've got after extensive searching and trial and
error, even thought I have to say I find it hard to believe?
Thanks
Matt

Nov 19 '05 #2

P: n/a
Ok, probably haven't explained it very well. Only wanted to do dynamic
labels to associate the HTML <label> tag with the correct radio button.

But ignoring the ID then for the moment (I actually also want to set the
'value' dynamically to, and which would have been better if I said that
instead of ID), how about dynamically setting the text?

E.g.
<asp:repeater ID="test" runat="server">
<itemtemplate>
<asp:RadioButton id="testid" Text="<%# Container.DataItem["myfield"]%>"
GroupName="testgroupname" runat="server"/>
</itemtemplate>
</asp:repeater>

?
Thanks
Matt

"london calling" <lo***********@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com...
Hi Matt,

You may be able to dynamically set the radiobutton's id but i dont think
it
would be very useful to you.

If you use the same id in the template, then by the INamingContainer
interface that the repeater implements, the ids will be unique on the
client
side (if accessing them from script) and you can still find the control by
myRepeaterItem.FindControl("myradiobuttonid")

HTH jd

"Matt Jensen" wrote:
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?
This is the impression I've got after extensive searching and trial and
error, even thought I have to say I find it hard to believe?
Thanks
Matt

Nov 19 '05 #3

P: n/a
Hi Matt, I have just done a little experiment... you can't set the
radiobutton's id but definately can set the text.

The "name" html attribute gets mangled by INamingContainer and the Value
gets set to the "ID".

So you would still have to loop through the repeater and inspect each radio
button to work out if it is checked and to find the text ... HTH jd

"london calling" wrote:
Hi Matt,

You may be able to dynamically set the radiobutton's id but i dont think it
would be very useful to you.

If you use the same id in the template, then by the INamingContainer
interface that the repeater implements, the ids will be unique on the client
side (if accessing them from script) and you can still find the control by
myRepeaterItem.FindControl("myradiobuttonid")

HTH jd

"Matt Jensen" wrote:
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?
This is the impression I've got after extensive searching and trial and
error, even thought I have to say I find it hard to believe?
Thanks
Matt

Nov 19 '05 #4

P: n/a
If you use an html radiobutton you may have less trouble, you could set any
attributes through databinding (<%# %> style) but if you don't set
runat="server" you won't have any mangling from INamingContainer.. just a
thought...

"Matt Jensen" wrote:
Ok, probably haven't explained it very well. Only wanted to do dynamic
labels to associate the HTML <label> tag with the correct radio button.

But ignoring the ID then for the moment (I actually also want to set the
'value' dynamically to, and which would have been better if I said that
instead of ID), how about dynamically setting the text?

E.g.
<asp:repeater ID="test" runat="server">
<itemtemplate>
<asp:RadioButton id="testid" Text="<%# Container.DataItem["myfield"]%>"
GroupName="testgroupname" runat="server"/>
</itemtemplate>
</asp:repeater>

?
Thanks
Matt

"london calling" <lo***********@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com...
Hi Matt,

You may be able to dynamically set the radiobutton's id but i dont think
it
would be very useful to you.

If you use the same id in the template, then by the INamingContainer
interface that the repeater implements, the ids will be unique on the
client
side (if accessing them from script) and you can still find the control by
myRepeaterItem.FindControl("myradiobuttonid")

HTH jd

"Matt Jensen" wrote:
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?
This is the impression I've got after extensive searching and trial and
error, even thought I have to say I find it hard to believe?
Thanks
Matt


Nov 19 '05 #5

P: n/a
Ok thanks jd, I'm probably going about it in the wrong way actually, still
thinking of it in terms of the classic ASP model of server/client
relationships, but currently I don't have time to worry about that....!
Looks like I'll just go with the basic HTML radio button element inside a
repeater (as you say)
Cheers
Matt

"london calling" <lo***********@discussions.microsoft.com> wrote in message
news:12**********************************@microsof t.com...
Hi Matt, I have just done a little experiment... you can't set the
radiobutton's id but definately can set the text.

The "name" html attribute gets mangled by INamingContainer and the Value
gets set to the "ID".

So you would still have to loop through the repeater and inspect each
radio
button to work out if it is checked and to find the text ... HTH jd

"london calling" wrote:
Hi Matt,

You may be able to dynamically set the radiobutton's id but i dont think
it
would be very useful to you.

If you use the same id in the template, then by the INamingContainer
interface that the repeater implements, the ids will be unique on the
client
side (if accessing them from script) and you can still find the control
by
myRepeaterItem.FindControl("myradiobuttonid")

HTH jd

"Matt Jensen" wrote:
> 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?
> This is the impression I've got after extensive searching and trial and
> error, even thought I have to say I find it hard to believe?
> Thanks
> Matt
>
>
>

Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.