Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Attaching a value to RadioButtons in a Repeater

Reply
Thread Tools

Attaching a value to RadioButtons in a Repeater

 
 
JesperGJensen
Guest
Posts: n/a
 
      02-04-2008
I need to select a date from a list of possible dates. I do this
through a Repeater

<asp:Repeater>
<ItemTemplate>
<RadioButton OnCheckedChanged="rptSelect_Changed">
<asp:Label> a date </asp:Label>
</ItemTemplate
</asp:Repeater>

In my current testcase there are 7 days to choose from. I use the
rptSelect_Changed function to handle the selection Serverside.
But how do i attach the date information to each RadioButton?
Currently i can only get basic RadioButton object. But this
radiobutton object does not know which date it represents.
When i did something similar with LinkButtons in a repeater i used
CommandArgument to attach the information.

How do i attach information to a radiobutton in this setup?
 
Reply With Quote
 
 
 
 
Coskun SUNALI [MVP]
Guest
Posts: n/a
 
      02-05-2008
Hi Jesper,

Try using the following code. In this sample, I find the parent control of
the RadioButton and get the Label placed in the same parent control. You can
access other child controls you may want to add in case you need to store
some other data inside them. (I haven't tried executing the code)

<asp:Repeater>
<ItemTemplate>
<RadioButton ID="rbDate" runat="server"
OnCheckedChanged="rptSelect_Changed">
<asp:Label ID="lbDate" runat="server"> a date </asp:Label>
</ItemTemplate
</asp:Repeater>


protected void rptSelect_Changed(object sender, EventArgs e)
{
RadioButton m_RB = (RadioButton)sender;
RepeaterItem m_RI = (RepeaterItem)m_RB.Parent;
Label m_L = (Label)m_RI.FindControl("lbDate");
string m_DateString = m_L.Text;
}

--
All the best,
Coskun SUNALI
MVP ASP/ASP.NET
http://sunali.com
http://www.propeople.dk


"JesperGJensen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I need to select a date from a list of possible dates. I do this
> through a Repeater
>
> <asp:Repeater>
> <ItemTemplate>
> <RadioButton OnCheckedChanged="rptSelect_Changed">
> <asp:Label> a date </asp:Label>
> </ItemTemplate
> </asp:Repeater>
>
> In my current testcase there are 7 days to choose from. I use the
> rptSelect_Changed function to handle the selection Serverside.
> But how do i attach the date information to each RadioButton?
> Currently i can only get basic RadioButton object. But this
> radiobutton object does not know which date it represents.
> When i did something similar with LinkButtons in a repeater i used
> CommandArgument to attach the information.
>
> How do i attach information to a radiobutton in this setup?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET: Repeater: RadioButtons in ItemTemplate Sachin ASP .Net 1 02-21-2006 08:47 PM
Dynamically add RadioButtons in Repeater =?Utf-8?B?Q2hyaXN0aWFhbiBOaWV1d2xhYXQ=?= ASP .Net 1 05-26-2005 11:50 AM
Help attaching validator controls to an undetermined number of contorls in a repeater Simon ASP .Net 1 05-17-2004 04:12 AM
RadioButtons & DataGrid RB ASP .Net 0 08-11-2003 04:29 PM
Radiobuttons and textbox with autopost Sean ASP .Net 1 08-06-2003 12:32 AM



Advertisments