Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Retrieving checked RadioButton controls which were added to a Table control

Reply
Thread Tools

Retrieving checked RadioButton controls which were added to a Table control

 
 
Anthony Williams
Guest
Posts: n/a
 
      09-08-2003
Hi gang,

I've created and populated a huge table, with 240 rows, with three cells per
row. There are 240 RadioButton controls for "TimeFrom", and 240 RadioButton
controls for "TimeTo".

RadioButtons appearing in cell 1 have a GroupName of "TimeFrom" and those
appearing in cell 2 have a GroupName of "TimeTo". The table appears
correctly (the code at the bottom of this post will generate it for you if
you create yourself a Table with ID "TSTable".

My problem, for those of you falling asleep by now, is that I haven't the
faintest idea of how to retrieve the "TimeFrom" and "TimeTo" selected
values. I can put a kludge together that will use Request.Form(...) but I
was rather hoping that there'd be a .NET way.

Any help would be greatly appreciated.

Cheers,
Tone


' ---------- Begin Create Table Code ----------
Dim CurTime As New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0)

For i As Integer = 0 To 240 ' 24 hours in 240 six-minute (1/10 hr)
increments

Dim Row As New TableRow
Dim CellFrom As New TableCell
Dim CellTo As New TableCell
Dim CellJob As New TableCell

CellFrom.Width = Unit.Pixel(60)
CellTo.Width = Unit.Pixel(60)

' Create a radio button control which will select the From time...
Dim RadioFrom As New RadioButton
RadioFrom.GroupName = "TimeFrom"
RadioFrom.EnableViewState = True
RadioFrom.Text = CurTime.AddMinutes(i * 6).ToShortTimeString

' ...then add it to the "From" cell we just created
CellFrom.Controls.Add(RadioFrom)

' And the same for selecting the To time...
Dim RadioTo As New RadioButton
RadioTo.GroupName = "TimeTo"
RadioTo.EnableViewState = True
RadioTo.Text = CurTime.AddMinutes(i * 6).ToShortTimeString

' ...then add it to the "To" cell
CellTo.Controls.Add(RadioTo)

With Row.Cells
.Add(CellFrom)
.Add(CellTo)
.Add(CellJob)
End With

RadioFrom.Dispose()
RadioTo.Dispose()

CellFrom.Dispose()
CellTo.Dispose()
CellJob.Dispose()

Row.Dispose()

Next
' ---------- End Create Table Code ----------


 
Reply With Quote
 
 
 
 
Lewis Wang [MSFT]
Guest
Posts: n/a
 
      09-09-2003
Hi Anthony,

You can put the 240 ShortTimeStrings in a DataSet/DataTable and bind it to
a RadioButtonList. Then we can get the selected radio text by "
RadioButtonList1.SelectedItem.ToString ()". Here is a code snippet for
demonstration, you may modify it to meet your requirements.

protected DataSet GetSource()
{
. .
if(Session["ds"]!=null)return (DataSet)Session["ds"];
DataSet ds=new DataSet();
DataTable newtable=new DataTable ();
DataColumn cc1 = new DataColumn("From",Type.GetType("System.String"),"" );
DataColumn cc2 = new DataColumn("To", Type.GetType("System.String"),"");
DataColumn cc3 = new DataColumn("Job", Type.GetType("System.String"),"");
newtable.Columns.Add(cc1);
newtable.Columns.Add(cc2);
newtable.Columns.Add(cc3);
for(int i=0; i<240;i++)
{
DataRow dr=newtable.NewRow ();
dr["From"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
dr["To"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
dr["Job"]="";
newtable.Rows .Add(dr);
}
ds.Tables .Add (newtable);
Session["ds"]=ds;

return ds;
}

private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
DataSet ds=GetSource();
RadioButtonList1.DataSource =ds;
RadioButtonList1.DataTextField ="From";
RadioButtonList1.DataBind ();
. . .
}
}

private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write ("From:" + RadioButtonList1.SelectedItem.ToString ());
. . .
}

Does this answer your question? Please let me know if you need more
information. Thanks.

Best regards,
Lewis
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: "Anthony Williams" <(E-Mail Removed)>
| Subject: Retrieving checked RadioButton controls which were added to a
Table control
| Date: Mon, 8 Sep 2003 12:28:26 +0100
| Lines: 73
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
| NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com 81.137.71.124
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontro ls:14469
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
|
| Hi gang,
|
| I've created and populated a huge table, with 240 rows, with three cells
per
| row. There are 240 RadioButton controls for "TimeFrom", and 240
RadioButton
| controls for "TimeTo".
|
| RadioButtons appearing in cell 1 have a GroupName of "TimeFrom" and those
| appearing in cell 2 have a GroupName of "TimeTo". The table appears
| correctly (the code at the bottom of this post will generate it for you if
| you create yourself a Table with ID "TSTable".
|
| My problem, for those of you falling asleep by now, is that I haven't the
| faintest idea of how to retrieve the "TimeFrom" and "TimeTo" selected
| values. I can put a kludge together that will use Request.Form(...) but I
| was rather hoping that there'd be a .NET way.
|
| Any help would be greatly appreciated.
|
| Cheers,
| Tone
|
|
| ' ---------- Begin Create Table Code ----------
| Dim CurTime As New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0)
|
| For i As Integer = 0 To 240 ' 24 hours in 240 six-minute (1/10 hr)
| increments
|
| Dim Row As New TableRow
| Dim CellFrom As New TableCell
| Dim CellTo As New TableCell
| Dim CellJob As New TableCell
|
| CellFrom.Width = Unit.Pixel(60)
| CellTo.Width = Unit.Pixel(60)
|
| ' Create a radio button control which will select the From time...
| Dim RadioFrom As New RadioButton
| RadioFrom.GroupName = "TimeFrom"
| RadioFrom.EnableViewState = True
| RadioFrom.Text = CurTime.AddMinutes(i * 6).ToShortTimeString
|
| ' ...then add it to the "From" cell we just created
| CellFrom.Controls.Add(RadioFrom)
|
| ' And the same for selecting the To time...
| Dim RadioTo As New RadioButton
| RadioTo.GroupName = "TimeTo"
| RadioTo.EnableViewState = True
| RadioTo.Text = CurTime.AddMinutes(i * 6).ToShortTimeString
|
| ' ...then add it to the "To" cell
| CellTo.Controls.Add(RadioTo)
|
| With Row.Cells
| .Add(CellFrom)
| .Add(CellTo)
| .Add(CellJob)
| End With
|
| RadioFrom.Dispose()
| RadioTo.Dispose()
|
| CellFrom.Dispose()
| CellTo.Dispose()
| CellJob.Dispose()
|
| Row.Dispose()
|
| Next
| ' ---------- End Create Table Code ----------
|
|
|

 
Reply With Quote
 
 
 
 
Anthony Williams
Guest
Posts: n/a
 
      09-09-2003
Lewis,

Thanks for the reply - not only did you manage to answer one question, but
you also tackled another which I was about to post to a different group -
namely how do I manually populate a dataset - hehe. Thanks for the reply,
but...

Because I've already manually populated a table with radiobutton controls,
I'm wondering whether or not it's possible to actually get the selected
value by group name - the reason I ask this specifically, is because I've
got a table with three columns - a radiobutton list won't allow me to keep
my format in this way (will it?)

Is there either a way to put the generated radiobutton list into a table
that already exists, or - possibly - add each of the radiobutton controls
not only to the table, but also to a radiobutton list?

Cheers,
Anthony


"Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Anthony,
>
> You can put the 240 ShortTimeStrings in a DataSet/DataTable and bind it to
> a RadioButtonList. Then we can get the selected radio text by "
> RadioButtonList1.SelectedItem.ToString ()". Here is a code snippet for
> demonstration, you may modify it to meet your requirements.
>
> protected DataSet GetSource()
> {
> . .
> if(Session["ds"]!=null)return (DataSet)Session["ds"];
> DataSet ds=new DataSet();
> DataTable newtable=new DataTable ();
> DataColumn cc1 = new DataColumn("From",Type.GetType("System.String"),"" );
> DataColumn cc2 = new DataColumn("To", Type.GetType("System.String"),"");
> DataColumn cc3 = new DataColumn("Job", Type.GetType("System.String"),"");
> newtable.Columns.Add(cc1);
> newtable.Columns.Add(cc2);
> newtable.Columns.Add(cc3);
> for(int i=0; i<240;i++)
> {
> DataRow dr=newtable.NewRow ();
> dr["From"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
> dr["To"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
> dr["Job"]="";
> newtable.Rows .Add(dr);
> }
> ds.Tables .Add (newtable);
> Session["ds"]=ds;
>
> return ds;
> }
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> if(!this.IsPostBack)
> {
> DataSet ds=GetSource();
> RadioButtonList1.DataSource =ds;
> RadioButtonList1.DataTextField ="From";
> RadioButtonList1.DataBind ();
> . . .
> }
> }
>
> private void Button1_Click(object sender, System.EventArgs e)
> {
> Response.Write ("From:" + RadioButtonList1.SelectedItem.ToString ());
> . . .
> }
>
> Does this answer your question? Please let me know if you need more
> information. Thanks.
>
> Best regards,
> Lewis
> This posting is provided "AS IS" with no warranties, and confers no

rights.
>
> --------------------
> | From: "Anthony Williams" <(E-Mail Removed)>
> | Subject: Retrieving checked RadioButton controls which were added to a
> Table control
> | Date: Mon, 8 Sep 2003 12:28:26 +0100
> | Lines: 73
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | Message-ID: <(E-Mail Removed)>
> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
> | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com

81.137.71.124
> | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
> | Xref: cpmsftngxa06.phx.gbl
> microsoft.public.dotnet.framework.aspnet.webcontro ls:14469
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
> |
> | Hi gang,
> |
> | I've created and populated a huge table, with 240 rows, with three cells
> per
> | row. There are 240 RadioButton controls for "TimeFrom", and 240
> RadioButton
> | controls for "TimeTo".
> |
> | RadioButtons appearing in cell 1 have a GroupName of "TimeFrom" and

those
> | appearing in cell 2 have a GroupName of "TimeTo". The table appears
> | correctly (the code at the bottom of this post will generate it for you

if
> | you create yourself a Table with ID "TSTable".
> |
> | My problem, for those of you falling asleep by now, is that I haven't

the
> | faintest idea of how to retrieve the "TimeFrom" and "TimeTo" selected
> | values. I can put a kludge together that will use Request.Form(...) but

I
> | was rather hoping that there'd be a .NET way.
> |
> | Any help would be greatly appreciated.
> |
> | Cheers,
> | Tone
> |
> |
> | ' ---------- Begin Create Table Code ----------
> | Dim CurTime As New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0)
> |
> | For i As Integer = 0 To 240 ' 24 hours in 240 six-minute (1/10 hr)
> | increments
> |
> | Dim Row As New TableRow
> | Dim CellFrom As New TableCell
> | Dim CellTo As New TableCell
> | Dim CellJob As New TableCell
> |
> | CellFrom.Width = Unit.Pixel(60)
> | CellTo.Width = Unit.Pixel(60)
> |
> | ' Create a radio button control which will select the From time...
> | Dim RadioFrom As New RadioButton
> | RadioFrom.GroupName = "TimeFrom"
> | RadioFrom.EnableViewState = True
> | RadioFrom.Text = CurTime.AddMinutes(i * 6).ToShortTimeString
> |
> | ' ...then add it to the "From" cell we just created
> | CellFrom.Controls.Add(RadioFrom)
> |
> | ' And the same for selecting the To time...
> | Dim RadioTo As New RadioButton
> | RadioTo.GroupName = "TimeTo"
> | RadioTo.EnableViewState = True
> | RadioTo.Text = CurTime.AddMinutes(i * 6).ToShortTimeString
> |
> | ' ...then add it to the "To" cell
> | CellTo.Controls.Add(RadioTo)
> |
> | With Row.Cells
> | .Add(CellFrom)
> | .Add(CellTo)
> | .Add(CellJob)
> | End With
> |
> | RadioFrom.Dispose()
> | RadioTo.Dispose()
> |
> | CellFrom.Dispose()
> | CellTo.Dispose()
> | CellJob.Dispose()
> |
> | Row.Dispose()
> |
> | Next
> | ' ---------- End Create Table Code ----------
> |
> |
> |
>



 
Reply With Quote
 
Lewis Wang [MSFT]
Guest
Posts: n/a
 
      09-09-2003
Hi Anthony,

It's possible to actually get the selected value by group name. But we need
to set the value attribution for every RadioButton. For example:

RadioFrom.Attributes .Add("value",RadioFrom.Text);

Then, we can get the selected value using Request.Form
["TimeFrom"].ToString () in code behind.

Hope this helps.

Best regards,
Lewis
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: "Anthony Williams" <(E-Mail Removed)>
| References: <(E-Mail Removed)>
<(E-Mail Removed)>
| Subject: Re: Retrieving checked RadioButton controls which were added to
a Table control
| Date: Tue, 9 Sep 2003 09:23:01 +0100
| Lines: 184
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
| NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com 81.137.71.124
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontro ls:14497
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
|
| Lewis,
|
| Thanks for the reply - not only did you manage to answer one question, but
| you also tackled another which I was about to post to a different group -
| namely how do I manually populate a dataset - hehe. Thanks for the reply,
| but...
|
| Because I've already manually populated a table with radiobutton controls,
| I'm wondering whether or not it's possible to actually get the selected
| value by group name - the reason I ask this specifically, is because I've
| got a table with three columns - a radiobutton list won't allow me to keep
| my format in this way (will it?)
|
| Is there either a way to put the generated radiobutton list into a table
| that already exists, or - possibly - add each of the radiobutton controls
| not only to the table, but also to a radiobutton list?
|
| Cheers,
| Anthony
|
|
| "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
| news:(E-Mail Removed)...
| > Hi Anthony,
| >
| > You can put the 240 ShortTimeStrings in a DataSet/DataTable and bind it
to
| > a RadioButtonList. Then we can get the selected radio text by "
| > RadioButtonList1.SelectedItem.ToString ()". Here is a code snippet for
| > demonstration, you may modify it to meet your requirements.
| >
| > protected DataSet GetSource()
| > {
| > . .
| > if(Session["ds"]!=null)return (DataSet)Session["ds"];
| > DataSet ds=new DataSet();
| > DataTable newtable=new DataTable ();
| > DataColumn cc1 = new
DataColumn("From",Type.GetType("System.String"),"" );
| > DataColumn cc2 = new DataColumn("To", Type.GetType("System.String"),"");
| > DataColumn cc3 = new DataColumn("Job",
Type.GetType("System.String"),"");
| > newtable.Columns.Add(cc1);
| > newtable.Columns.Add(cc2);
| > newtable.Columns.Add(cc3);
| > for(int i=0; i<240;i++)
| > {
| > DataRow dr=newtable.NewRow ();
| > dr["From"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
| > dr["To"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
| > dr["Job"]="";
| > newtable.Rows .Add(dr);
| > }
| > ds.Tables .Add (newtable);
| > Session["ds"]=ds;
| >
| > return ds;
| > }
| >
| > private void Page_Load(object sender, System.EventArgs e)
| > {
| > if(!this.IsPostBack)
| > {
| > DataSet ds=GetSource();
| > RadioButtonList1.DataSource =ds;
| > RadioButtonList1.DataTextField ="From";
| > RadioButtonList1.DataBind ();
| > . . .
| > }
| > }
| >
| > private void Button1_Click(object sender, System.EventArgs e)
| > {
| > Response.Write ("From:" + RadioButtonList1.SelectedItem.ToString ());
| > . . .
| > }
| >
| > Does this answer your question? Please let me know if you need more
| > information. Thanks.
| >
| > Best regards,
| > Lewis
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| >
| > --------------------
| > | From: "Anthony Williams" <(E-Mail Removed)>
| > | Subject: Retrieving checked RadioButton controls which were added to a
| > Table control
| > | Date: Mon, 8 Sep 2003 12:28:26 +0100
| > | Lines: 73
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <(E-Mail Removed)>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
| > | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com
| 81.137.71.124
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.webcontro ls:14469
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
| > |
| > | Hi gang,
| > |
| > | I've created and populated a huge table, with 240 rows, with three
cells
| > per
| > | row. There are 240 RadioButton controls for "TimeFrom", and 240
| > RadioButton
| > | controls for "TimeTo".
| > |
| > | RadioButtons appearing in cell 1 have a GroupName of "TimeFrom" and
| those
| > | appearing in cell 2 have a GroupName of "TimeTo". The table appears
| > | correctly (the code at the bottom of this post will generate it for
you
| if
| > | you create yourself a Table with ID "TSTable".
| > |
| > | My problem, for those of you falling asleep by now, is that I haven't
| the
| > | faintest idea of how to retrieve the "TimeFrom" and "TimeTo" selected
| > | values. I can put a kludge together that will use Request.Form(...)
but
| I
| > | was rather hoping that there'd be a .NET way.
| > |
| > | Any help would be greatly appreciated.
| > |
| > | Cheers,
| > | Tone
| > |
| > |
| > | ' ---------- Begin Create Table Code ----------
| > | Dim CurTime As New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0)
| > |
| > | For i As Integer = 0 To 240 ' 24 hours in 240 six-minute (1/10 hr)
| > | increments
| > |
| > | Dim Row As New TableRow
| > | Dim CellFrom As New TableCell
| > | Dim CellTo As New TableCell
| > | Dim CellJob As New TableCell
| > |
| > | CellFrom.Width = Unit.Pixel(60)
| > | CellTo.Width = Unit.Pixel(60)
| > |
| > | ' Create a radio button control which will select the From time...
| > | Dim RadioFrom As New RadioButton
| > | RadioFrom.GroupName = "TimeFrom"
| > | RadioFrom.EnableViewState = True
| > | RadioFrom.Text = CurTime.AddMinutes(i * 6).ToShortTimeString
| > |
| > | ' ...then add it to the "From" cell we just created
| > | CellFrom.Controls.Add(RadioFrom)
| > |
| > | ' And the same for selecting the To time...
| > | Dim RadioTo As New RadioButton
| > | RadioTo.GroupName = "TimeTo"
| > | RadioTo.EnableViewState = True
| > | RadioTo.Text = CurTime.AddMinutes(i * 6).ToShortTimeString
| > |
| > | ' ...then add it to the "To" cell
| > | CellTo.Controls.Add(RadioTo)
| > |
| > | With Row.Cells
| > | .Add(CellFrom)
| > | .Add(CellTo)
| > | .Add(CellJob)
| > | End With
| > |
| > | RadioFrom.Dispose()
| > | RadioTo.Dispose()
| > |
| > | CellFrom.Dispose()
| > | CellTo.Dispose()
| > | CellJob.Dispose()
| > |
| > | Row.Dispose()
| > |
| > | Next
| > | ' ---------- End Create Table Code ----------
| > |
| > |
| > |
| >
|
|
|

 
Reply With Quote
 
Lewis Wang [MSFT]
Guest
Posts: n/a
 
      09-09-2003
Hi Anthony,

I need more information to resolve the questions mentioned in the last
paragraph of your post.

What do you mean about putting the generated radiobutton list into a table?
Do you mean you want to put a radiobuttonlist control to a TableCell, or do
you mean you want to put each radio control in the radiobuttonlist to each
TableCell of a Table column?

Thanks a lot.

Lewis

--------------------
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
| From: http://www.velocityreviews.com/forums/(E-Mail Removed) (Lewis Wang [MSFT])
| Organization: Microsoft
| Date: Tue, 09 Sep 2003 15:08:10 GMT
| Subject: Re: Retrieving checked RadioButton controls which were added to
a Table control
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
|
| Hi Anthony,
|
| It's possible to actually get the selected value by group name. But we
need
| to set the value attribution for every RadioButton. For example:
|
| RadioFrom.Attributes .Add("value",RadioFrom.Text);
|
| Then, we can get the selected value using Request.Form
| ["TimeFrom"].ToString () in code behind.
|
| Hope this helps.
|
| Best regards,
| Lewis
| This posting is provided "AS IS" with no warranties, and confers no
rights.
|
| --------------------
| | From: "Anthony Williams" <(E-Mail Removed)>
| | References: <(E-Mail Removed)>
| <(E-Mail Removed)>
| | Subject: Re: Retrieving checked RadioButton controls which were added
to
| a Table control
| | Date: Tue, 9 Sep 2003 09:23:01 +0100
| | Lines: 184
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| | Message-ID: <(E-Mail Removed)>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
| | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com
81.137.71.124
| | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| | Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.aspnet.webcontro ls:14497
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
| |
| | Lewis,
| |
| | Thanks for the reply - not only did you manage to answer one question,
but
| | you also tackled another which I was about to post to a different group
-
| | namely how do I manually populate a dataset - hehe. Thanks for the
reply,
| | but...
| |
| | Because I've already manually populated a table with radiobutton
controls,
| | I'm wondering whether or not it's possible to actually get the selected
| | value by group name - the reason I ask this specifically, is because
I've
| | got a table with three columns - a radiobutton list won't allow me to
keep
| | my format in this way (will it?)
| |
| | Is there either a way to put the generated radiobutton list into a table
| | that already exists, or - possibly - add each of the radiobutton
controls
| | not only to the table, but also to a radiobutton list?
| |
| | Cheers,
| | Anthony
| |
| |
| | "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
| | news:(E-Mail Removed)...
| | > Hi Anthony,
| | >
| | > You can put the 240 ShortTimeStrings in a DataSet/DataTable and bind
it
| to
| | > a RadioButtonList. Then we can get the selected radio text by "
| | > RadioButtonList1.SelectedItem.ToString ()". Here is a code snippet for
| | > demonstration, you may modify it to meet your requirements.
| | >
| | > protected DataSet GetSource()
| | > {
| | > . .
| | > if(Session["ds"]!=null)return (DataSet)Session["ds"];
| | > DataSet ds=new DataSet();
| | > DataTable newtable=new DataTable ();
| | > DataColumn cc1 = new
| DataColumn("From",Type.GetType("System.String"),"" );
| | > DataColumn cc2 = new DataColumn("To",
Type.GetType("System.String"),"");
| | > DataColumn cc3 = new DataColumn("Job",
| Type.GetType("System.String"),"");
| | > newtable.Columns.Add(cc1);
| | > newtable.Columns.Add(cc2);
| | > newtable.Columns.Add(cc3);
| | > for(int i=0; i<240;i++)
| | > {
| | > DataRow dr=newtable.NewRow ();
| | > dr["From"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
| | > dr["To"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
| | > dr["Job"]="";
| | > newtable.Rows .Add(dr);
| | > }
| | > ds.Tables .Add (newtable);
| | > Session["ds"]=ds;
| | >
| | > return ds;
| | > }
| | >
| | > private void Page_Load(object sender, System.EventArgs e)
| | > {
| | > if(!this.IsPostBack)
| | > {
| | > DataSet ds=GetSource();
| | > RadioButtonList1.DataSource =ds;
| | > RadioButtonList1.DataTextField ="From";
| | > RadioButtonList1.DataBind ();
| | > . . .
| | > }
| | > }
| | >
| | > private void Button1_Click(object sender, System.EventArgs e)
| | > {
| | > Response.Write ("From:" + RadioButtonList1.SelectedItem.ToString ());
| | > . . .
| | > }
| | >
| | > Does this answer your question? Please let me know if you need more
| | > information. Thanks.
| | >
| | > Best regards,
| | > Lewis
| | > This posting is provided "AS IS" with no warranties, and confers no
| | rights.
| | >
| | > --------------------
| | > | From: "Anthony Williams" <(E-Mail Removed)>
| | > | Subject: Retrieving checked RadioButton controls which were added
to a
| | > Table control
| | > | Date: Mon, 8 Sep 2003 12:28:26 +0100
| | > | Lines: 73
| | > | X-Priority: 3
| | > | X-MSMail-Priority: Normal
| | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| | > | Message-ID: <(E-Mail Removed)>
| | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
| | > | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com
| | 81.137.71.124
| | > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| | > | Xref: cpmsftngxa06.phx.gbl
| | > microsoft.public.dotnet.framework.aspnet.webcontro ls:14469
| | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
| | > |
| | > | Hi gang,
| | > |
| | > | I've created and populated a huge table, with 240 rows, with three
| cells
| | > per
| | > | row. There are 240 RadioButton controls for "TimeFrom", and 240
| | > RadioButton
| | > | controls for "TimeTo".
| | > |
| | > | RadioButtons appearing in cell 1 have a GroupName of "TimeFrom" and
| | those
| | > | appearing in cell 2 have a GroupName of "TimeTo". The table appears
| | > | correctly (the code at the bottom of this post will generate it for
| you
| | if
| | > | you create yourself a Table with ID "TSTable".
| | > |
| | > | My problem, for those of you falling asleep by now, is that I
haven't
| | the
| | > | faintest idea of how to retrieve the "TimeFrom" and "TimeTo"
selected
| | > | values. I can put a kludge together that will use Request.Form(...)
| but
| | I
| | > | was rather hoping that there'd be a .NET way.
| | > |
| | > | Any help would be greatly appreciated.
| | > |
| | > | Cheers,
| | > | Tone
| | > |
| | > |
| | > | ' ---------- Begin Create Table Code ----------
| | > | Dim CurTime As New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0)
| | > |
| | > | For i As Integer = 0 To 240 ' 24 hours in 240 six-minute (1/10 hr)
| | > | increments
| | > |
| | > | Dim Row As New TableRow
| | > | Dim CellFrom As New TableCell
| | > | Dim CellTo As New TableCell
| | > | Dim CellJob As New TableCell
| | > |
| | > | CellFrom.Width = Unit.Pixel(60)
| | > | CellTo.Width = Unit.Pixel(60)
| | > |
| | > | ' Create a radio button control which will select the From
time...
| | > | Dim RadioFrom As New RadioButton
| | > | RadioFrom.GroupName = "TimeFrom"
| | > | RadioFrom.EnableViewState = True
| | > | RadioFrom.Text = CurTime.AddMinutes(i * 6).ToShortTimeString
| | > |
| | > | ' ...then add it to the "From" cell we just created
| | > | CellFrom.Controls.Add(RadioFrom)
| | > |
| | > | ' And the same for selecting the To time...
| | > | Dim RadioTo As New RadioButton
| | > | RadioTo.GroupName = "TimeTo"
| | > | RadioTo.EnableViewState = True
| | > | RadioTo.Text = CurTime.AddMinutes(i * 6).ToShortTimeString
| | > |
| | > | ' ...then add it to the "To" cell
| | > | CellTo.Controls.Add(RadioTo)
| | > |
| | > | With Row.Cells
| | > | .Add(CellFrom)
| | > | .Add(CellTo)
| | > | .Add(CellJob)
| | > | End With
| | > |
| | > | RadioFrom.Dispose()
| | > | RadioTo.Dispose()
| | > |
| | > | CellFrom.Dispose()
| | > | CellTo.Dispose()
| | > | CellJob.Dispose()
| | > |
| | > | Row.Dispose()
| | > |
| | > | Next
| | > | ' ---------- End Create Table Code ----------
| | > |
| | > |
| | > |
| | >
| |
| |
| |
|

 
Reply With Quote
 
Anthony Williams
Guest
Posts: n/a
 
      09-10-2003
Lewis,

Sorry for the long answer, but basically, I thought it best to explain
exactly what I'm doing here.

I have created a user control which contains a calendar control and this
free busy list which I'm creating. The date, as selected by the calendar
control sets a DateTime variable on the page to the current date. The
Free/Busy list then displays times from midnight on that day to midnight the
following day - a 24-hour block of 6-minute intervals.

Ideally, I'd like to generate a table with 4 cells, like so:

[Time] [Fr] [To] [Free/Busy]
00:00 () ()
00:06 () ()
00:12 () ()
...... () ()
23:48 () ()
23:54 () ()
00:00 () ()

Cell [Time] would contain the time, cells [Fr(om)] and [To] would contain a
RadioButton control, the value of which would be the Date and Time passed,
so that the end-user can select a "From" time and a "To" time. Cell
[Free/Busy] just contains information which is returned by a stored
procedure, which is the source for the information.

So, my questions are:

1.
Since I have set all of the radiobutton controls to have the same GroupName
(either "TimeFrom" or "TimeTo") is it possible to find out the control name
of the radiobutton checked in each group - a function that you could pass
the GroupName to which would return either the name of the checked
radiobutton control (great) or the value of the checked radiobutton control
(even better).

Even if a function has to be written (I'm thinking something along the lines
of CheckedRadioButton(ByVal GroupName As String) As RadioButton) it's got to
be better than the current state of affairs ) Any help you can offer in
terms of writing such a function would be greatly appreciated - I presume it
would have something to do with looping through each of the controls in the
User Control or the page with the GroupName as given, and then checking to
see if ThatRadioButton.Checked is True...

(PS - something like that should be added to the next point release, or
definately ASP.NET v2.0)

2.
Failing that, is there a way of creating a radiobutton list, and then taking
the rows that are generated by said radiobutton list, and adding them to a
table that already exists - either a System.Web.UI.WebControls.Table or a
System.Web.UI.HtmlControls.HtmlTable - and still be able to query the
RadioButtonList.SelectedValue value?

3.
Failing both of the above, what would you suggest? )


Cheers Lewis,
Anth



"Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Anthony,
>
> I need more information to resolve the questions mentioned in the last
> paragraph of your post.
>
> What do you mean about putting the generated radiobutton list into a

table?
> Do you mean you want to put a radiobuttonlist control to a TableCell, or

do
> you mean you want to put each radio control in the radiobuttonlist to each
> TableCell of a Table column?
>
> Thanks a lot.
>
> Lewis
>
> --------------------
> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
> | From: (E-Mail Removed) (Lewis Wang [MSFT])
> | Organization: Microsoft
> | Date: Tue, 09 Sep 2003 15:08:10 GMT
> | Subject: Re: Retrieving checked RadioButton controls which were added to
> a Table control
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
> | MIME-Version: 1.0
> | Content-Type: text/plain
> | Content-Transfer-Encoding: 7bit
> |
> | Hi Anthony,
> |
> | It's possible to actually get the selected value by group name. But we
> need
> | to set the value attribution for every RadioButton. For example:
> |
> | RadioFrom.Attributes .Add("value",RadioFrom.Text);
> |
> | Then, we can get the selected value using Request.Form
> | ["TimeFrom"].ToString () in code behind.
> |
> | Hope this helps.
> |
> | Best regards,
> | Lewis
> | This posting is provided "AS IS" with no warranties, and confers no
> rights.
> |
> | --------------------
> | | From: "Anthony Williams" <(E-Mail Removed)>
> | | References: <(E-Mail Removed)>
> | <(E-Mail Removed)>
> | | Subject: Re: Retrieving checked RadioButton controls which were added
> to
> | a Table control
> | | Date: Tue, 9 Sep 2003 09:23:01 +0100
> | | Lines: 184
> | | X-Priority: 3
> | | X-MSMail-Priority: Normal
> | | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | | Message-ID: <(E-Mail Removed)>
> | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
> | | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com
> 81.137.71.124
> | | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
> | | Xref: cpmsftngxa06.phx.gbl
> | microsoft.public.dotnet.framework.aspnet.webcontro ls:14497
> | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
> | |
> | | Lewis,
> | |
> | | Thanks for the reply - not only did you manage to answer one question,
> but
> | | you also tackled another which I was about to post to a different

group
> -
> | | namely how do I manually populate a dataset - hehe. Thanks for the
> reply,
> | | but...
> | |
> | | Because I've already manually populated a table with radiobutton
> controls,
> | | I'm wondering whether or not it's possible to actually get the

selected
> | | value by group name - the reason I ask this specifically, is because
> I've
> | | got a table with three columns - a radiobutton list won't allow me to
> keep
> | | my format in this way (will it?)
> | |
> | | Is there either a way to put the generated radiobutton list into a

table
> | | that already exists, or - possibly - add each of the radiobutton
> controls
> | | not only to the table, but also to a radiobutton list?
> | |
> | | Cheers,
> | | Anthony
> | |
> | |
> | | "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
> | | news:(E-Mail Removed)...
> | | > Hi Anthony,
> | | >
> | | > You can put the 240 ShortTimeStrings in a DataSet/DataTable and bind
> it
> | to
> | | > a RadioButtonList. Then we can get the selected radio text by "
> | | > RadioButtonList1.SelectedItem.ToString ()". Here is a code snippet

for
> | | > demonstration, you may modify it to meet your requirements.
> | | >
> | | > protected DataSet GetSource()
> | | > {
> | | > . .
> | | > if(Session["ds"]!=null)return (DataSet)Session["ds"];
> | | > DataSet ds=new DataSet();
> | | > DataTable newtable=new DataTable ();
> | | > DataColumn cc1 = new
> | DataColumn("From",Type.GetType("System.String"),"" );
> | | > DataColumn cc2 = new DataColumn("To",
> Type.GetType("System.String"),"");
> | | > DataColumn cc3 = new DataColumn("Job",
> | Type.GetType("System.String"),"");
> | | > newtable.Columns.Add(cc1);
> | | > newtable.Columns.Add(cc2);
> | | > newtable.Columns.Add(cc3);
> | | > for(int i=0; i<240;i++)
> | | > {
> | | > DataRow dr=newtable.NewRow ();
> | | > dr["From"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
> | | > dr["To"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
> | | > dr["Job"]="";
> | | > newtable.Rows .Add(dr);
> | | > }
> | | > ds.Tables .Add (newtable);
> | | > Session["ds"]=ds;
> | | >
> | | > return ds;
> | | > }
> | | >
> | | > private void Page_Load(object sender, System.EventArgs e)
> | | > {
> | | > if(!this.IsPostBack)
> | | > {
> | | > DataSet ds=GetSource();
> | | > RadioButtonList1.DataSource =ds;
> | | > RadioButtonList1.DataTextField ="From";
> | | > RadioButtonList1.DataBind ();
> | | > . . .
> | | > }
> | | > }
> | | >
> | | > private void Button1_Click(object sender, System.EventArgs e)
> | | > {
> | | > Response.Write ("From:" + RadioButtonList1.SelectedItem.ToString

());
> | | > . . .
> | | > }
> | | >
> | | > Does this answer your question? Please let me know if you need more
> | | > information. Thanks.
> | | >
> | | > Best regards,
> | | > Lewis
> | | > This posting is provided "AS IS" with no warranties, and confers no
> | | rights.
> | | >
> | | > --------------------
> | | > | From: "Anthony Williams" <(E-Mail Removed)>
> | | > | Subject: Retrieving checked RadioButton controls which were added
> to a
> | | > Table control
> | | > | Date: Mon, 8 Sep 2003 12:28:26 +0100
> | | > | Lines: 73
> | | > | X-Priority: 3
> | | > | X-MSMail-Priority: Normal
> | | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | | > | Message-ID: <(E-Mail Removed)>
> | | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
> | | > | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com
> | | 81.137.71.124
> | | > | Path:

cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
> | | > | Xref: cpmsftngxa06.phx.gbl
> | | > microsoft.public.dotnet.framework.aspnet.webcontro ls:14469
> | | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
> | | > |
> | | > | Hi gang,
> | | > |
> | | > | I've created and populated a huge table, with 240 rows, with three
> | cells
> | | > per
> | | > | row. There are 240 RadioButton controls for "TimeFrom", and 240
> | | > RadioButton
> | | > | controls for "TimeTo".
> | | > |
> | | > | RadioButtons appearing in cell 1 have a GroupName of "TimeFrom"

and
> | | those
> | | > | appearing in cell 2 have a GroupName of "TimeTo". The table

appears
> | | > | correctly (the code at the bottom of this post will generate it

for
> | you
> | | if
> | | > | you create yourself a Table with ID "TSTable".
> | | > |
> | | > | My problem, for those of you falling asleep by now, is that I
> haven't
> | | the
> | | > | faintest idea of how to retrieve the "TimeFrom" and "TimeTo"
> selected
> | | > | values. I can put a kludge together that will use

Request.Form(...)
> | but
> | | I
> | | > | was rather hoping that there'd be a .NET way.
> | | > |
> | | > | Any help would be greatly appreciated.
> | | > |
> | | > | Cheers,
> | | > | Tone
> | | > |
> | | > |
> | | > | ' ---------- Begin Create Table Code ----------
> | | > | Dim CurTime As New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0)
> | | > |
> | | > | For i As Integer = 0 To 240 ' 24 hours in 240 six-minute (1/10 hr)
> | | > | increments
> | | > |
> | | > | Dim Row As New TableRow
> | | > | Dim CellFrom As New TableCell
> | | > | Dim CellTo As New TableCell
> | | > | Dim CellJob As New TableCell
> | | > |
> | | > | CellFrom.Width = Unit.Pixel(60)
> | | > | CellTo.Width = Unit.Pixel(60)
> | | > |
> | | > | ' Create a radio button control which will select the From
> time...
> | | > | Dim RadioFrom As New RadioButton
> | | > | RadioFrom.GroupName = "TimeFrom"
> | | > | RadioFrom.EnableViewState = True
> | | > | RadioFrom.Text = CurTime.AddMinutes(i * 6).ToShortTimeString
> | | > |
> | | > | ' ...then add it to the "From" cell we just created
> | | > | CellFrom.Controls.Add(RadioFrom)
> | | > |
> | | > | ' And the same for selecting the To time...
> | | > | Dim RadioTo As New RadioButton
> | | > | RadioTo.GroupName = "TimeTo"
> | | > | RadioTo.EnableViewState = True
> | | > | RadioTo.Text = CurTime.AddMinutes(i * 6).ToShortTimeString
> | | > |
> | | > | ' ...then add it to the "To" cell
> | | > | CellTo.Controls.Add(RadioTo)
> | | > |
> | | > | With Row.Cells
> | | > | .Add(CellFrom)
> | | > | .Add(CellTo)
> | | > | .Add(CellJob)
> | | > | End With
> | | > |
> | | > | RadioFrom.Dispose()
> | | > | RadioTo.Dispose()
> | | > |
> | | > | CellFrom.Dispose()
> | | > | CellTo.Dispose()
> | | > | CellJob.Dispose()
> | | > |
> | | > | Row.Dispose()
> | | > |
> | | > | Next
> | | > | ' ---------- End Create Table Code ----------
> | | > |
> | | > |
> | | > |
> | | >
> | |
> | |
> | |
> |
>



 
Reply With Quote
 
Lewis Wang [MSFT]
Guest
Posts: n/a
 
      09-11-2003
Hi Anthony,

Does the solution in my prior post meet your requirements?

It's possible to actually get the selected value by group name. But we need
to set the value attribution for every RadioButton. For example:

RadioFrom.Attributes .Add("value",RadioFrom.Text); Then, we add these radio
buttons to the table using the method in your first post.

Then, we can get the selected radio value using Request.Form["groupname
"].ToString () in code behind.

If we want to loop through each of the radio control in the User Control or
the page to check which radio button was checked using client side script,
we can do that like this:

1. Set the id for each radio control, something like: radio1,
radio2,**
2. Set the same "groupname" for each radio control.
3. The client side script may like this:
<script language="javascript">
function checkradios(){
for(i=1;i<n;i++)
if(document.all("radio"+i).checked)
alert(document.all("radio"+i).value);
}
</script>

Does this answer your question? Please let me know if you need more
information.

Best regards,
Lewis
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: "Anthony Williams" <(E-Mail Removed)>
| References: <(E-Mail Removed)>
<(E-Mail Removed)>
<(E-Mail Removed)>
<(E-Mail Removed)>
<(E-Mail Removed)>
| Subject: Re: Retrieving checked RadioButton controls which were added to
a Table control
| Date: Wed, 10 Sep 2003 12:37:07 +0100
| Lines: 353
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#H0Of$(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
| NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com 81.137.71.124
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontro ls:14530
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
|
| Lewis,
|
| Sorry for the long answer, but basically, I thought it best to explain
| exactly what I'm doing here.
|
| I have created a user control which contains a calendar control and this
| free busy list which I'm creating. The date, as selected by the calendar
| control sets a DateTime variable on the page to the current date. The
| Free/Busy list then displays times from midnight on that day to midnight
the
| following day - a 24-hour block of 6-minute intervals.
|
| Ideally, I'd like to generate a table with 4 cells, like so:
|
| [Time] [Fr] [To] [Free/Busy]
| 00:00 () ()
| 00:06 () ()
| 00:12 () ()
| ..... () ()
| 23:48 () ()
| 23:54 () ()
| 00:00 () ()
|
| Cell [Time] would contain the time, cells [Fr(om)] and [To] would contain
a
| RadioButton control, the value of which would be the Date and Time passed,
| so that the end-user can select a "From" time and a "To" time. Cell
| [Free/Busy] just contains information which is returned by a stored
| procedure, which is the source for the information.
|
| So, my questions are:
|
| 1.
| Since I have set all of the radiobutton controls to have the same
GroupName
| (either "TimeFrom" or "TimeTo") is it possible to find out the control
name
| of the radiobutton checked in each group - a function that you could pass
| the GroupName to which would return either the name of the checked
| radiobutton control (great) or the value of the checked radiobutton
control
| (even better).
|
| Even if a function has to be written (I'm thinking something along the
lines
| of CheckedRadioButton(ByVal GroupName As String) As RadioButton) it's got
to
| be better than the current state of affairs ) Any help you can offer in
| terms of writing such a function would be greatly appreciated - I presume
it
| would have something to do with looping through each of the controls in
the
| User Control or the page with the GroupName as given, and then checking to
| see if ThatRadioButton.Checked is True...
|
| (PS - something like that should be added to the next point release, or
| definately ASP.NET v2.0)
|
| 2.
| Failing that, is there a way of creating a radiobutton list, and then
taking
| the rows that are generated by said radiobutton list, and adding them to a
| table that already exists - either a System.Web.UI.WebControls.Table or a
| System.Web.UI.HtmlControls.HtmlTable - and still be able to query the
| RadioButtonList.SelectedValue value?
|
| 3.
| Failing both of the above, what would you suggest? )
|
|
| Cheers Lewis,
| Anth
|
|
|
| "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
| news:(E-Mail Removed)...
| > Hi Anthony,
| >
| > I need more information to resolve the questions mentioned in the last
| > paragraph of your post.
| >
| > What do you mean about putting the generated radiobutton list into a
| table?
| > Do you mean you want to put a radiobuttonlist control to a TableCell, or
| do
| > you mean you want to put each radio control in the radiobuttonlist to
each
| > TableCell of a Table column?
| >
| > Thanks a lot.
| >
| > Lewis
| >
| > --------------------
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
| > | From: (E-Mail Removed) (Lewis Wang [MSFT])
| > | Organization: Microsoft
| > | Date: Tue, 09 Sep 2003 15:08:10 GMT
| > | Subject: Re: Retrieving checked RadioButton controls which were added
to
| > a Table control
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
| > | MIME-Version: 1.0
| > | Content-Type: text/plain
| > | Content-Transfer-Encoding: 7bit
| > |
| > | Hi Anthony,
| > |
| > | It's possible to actually get the selected value by group name. But we
| > need
| > | to set the value attribution for every RadioButton. For example:
| > |
| > | RadioFrom.Attributes .Add("value",RadioFrom.Text);
| > |
| > | Then, we can get the selected value using Request.Form
| > | ["TimeFrom"].ToString () in code behind.
| > |
| > | Hope this helps.
| > |
| > | Best regards,
| > | Lewis
| > | This posting is provided "AS IS" with no warranties, and confers no
| > rights.
| > |
| > | --------------------
| > | | From: "Anthony Williams" <(E-Mail Removed)>
| > | | References: <(E-Mail Removed)>
| > | <(E-Mail Removed)>
| > | | Subject: Re: Retrieving checked RadioButton controls which were
added
| > to
| > | a Table control
| > | | Date: Tue, 9 Sep 2003 09:23:01 +0100
| > | | Lines: 184
| > | | X-Priority: 3
| > | | X-MSMail-Priority: Normal
| > | | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | | Message-ID: <(E-Mail Removed)>
| > | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
| > | | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com
| > 81.137.71.124
| > | | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| > | | Xref: cpmsftngxa06.phx.gbl
| > | microsoft.public.dotnet.framework.aspnet.webcontro ls:14497
| > | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
| > | |
| > | | Lewis,
| > | |
| > | | Thanks for the reply - not only did you manage to answer one
question,
| > but
| > | | you also tackled another which I was about to post to a different
| group
| > -
| > | | namely how do I manually populate a dataset - hehe. Thanks for the
| > reply,
| > | | but...
| > | |
| > | | Because I've already manually populated a table with radiobutton
| > controls,
| > | | I'm wondering whether or not it's possible to actually get the
| selected
| > | | value by group name - the reason I ask this specifically, is because
| > I've
| > | | got a table with three columns - a radiobutton list won't allow me
to
| > keep
| > | | my format in this way (will it?)
| > | |
| > | | Is there either a way to put the generated radiobutton list into a
| table
| > | | that already exists, or - possibly - add each of the radiobutton
| > controls
| > | | not only to the table, but also to a radiobutton list?
| > | |
| > | | Cheers,
| > | | Anthony
| > | |
| > | |
| > | | "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
| > | | news:(E-Mail Removed)...
| > | | > Hi Anthony,
| > | | >
| > | | > You can put the 240 ShortTimeStrings in a DataSet/DataTable and
bind
| > it
| > | to
| > | | > a RadioButtonList. Then we can get the selected radio text by "
| > | | > RadioButtonList1.SelectedItem.ToString ()". Here is a code snippet
| for
| > | | > demonstration, you may modify it to meet your requirements.
| > | | >
| > | | > protected DataSet GetSource()
| > | | > {
| > | | > . .
| > | | > if(Session["ds"]!=null)return (DataSet)Session["ds"];
| > | | > DataSet ds=new DataSet();
| > | | > DataTable newtable=new DataTable ();
| > | | > DataColumn cc1 = new
| > | DataColumn("From",Type.GetType("System.String"),"" );
| > | | > DataColumn cc2 = new DataColumn("To",
| > Type.GetType("System.String"),"");
| > | | > DataColumn cc3 = new DataColumn("Job",
| > | Type.GetType("System.String"),"");
| > | | > newtable.Columns.Add(cc1);
| > | | > newtable.Columns.Add(cc2);
| > | | > newtable.Columns.Add(cc3);
| > | | > for(int i=0; i<240;i++)
| > | | > {
| > | | > DataRow dr=newtable.NewRow ();
| > | | > dr["From"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
| > | | > dr["To"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
| > | | > dr["Job"]="";
| > | | > newtable.Rows .Add(dr);
| > | | > }
| > | | > ds.Tables .Add (newtable);
| > | | > Session["ds"]=ds;
| > | | >
| > | | > return ds;
| > | | > }
| > | | >
| > | | > private void Page_Load(object sender, System.EventArgs e)
| > | | > {
| > | | > if(!this.IsPostBack)
| > | | > {
| > | | > DataSet ds=GetSource();
| > | | > RadioButtonList1.DataSource =ds;
| > | | > RadioButtonList1.DataTextField ="From";
| > | | > RadioButtonList1.DataBind ();
| > | | > . . .
| > | | > }
| > | | > }
| > | | >
| > | | > private void Button1_Click(object sender, System.EventArgs e)
| > | | > {
| > | | > Response.Write ("From:" + RadioButtonList1.SelectedItem.ToString
| ());
| > | | > . . .
| > | | > }
| > | | >
| > | | > Does this answer your question? Please let me know if you need
more
| > | | > information. Thanks.
| > | | >
| > | | > Best regards,
| > | | > Lewis
| > | | > This posting is provided "AS IS" with no warranties, and confers
no
| > | | rights.
| > | | >
| > | | > --------------------
| > | | > | From: "Anthony Williams" <(E-Mail Removed)>
| > | | > | Subject: Retrieving checked RadioButton controls which were
added
| > to a
| > | | > Table control
| > | | > | Date: Mon, 8 Sep 2003 12:28:26 +0100
| > | | > | Lines: 73
| > | | > | X-Priority: 3
| > | | > | X-MSMail-Priority: Normal
| > | | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | | > | Message-ID: <(E-Mail Removed)>
| > | | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
| > | | > | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com
| > | | 81.137.71.124
| > | | > | Path:
| cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| > | | > | Xref: cpmsftngxa06.phx.gbl
| > | | > microsoft.public.dotnet.framework.aspnet.webcontro ls:14469
| > | | > | X-Tomcat-NG:
microsoft.public.dotnet.framework.aspnet.webcontro ls
| > | | > |
| > | | > | Hi gang,
| > | | > |
| > | | > | I've created and populated a huge table, with 240 rows, with
three
| > | cells
| > | | > per
| > | | > | row. There are 240 RadioButton controls for "TimeFrom", and 240
| > | | > RadioButton
| > | | > | controls for "TimeTo".
| > | | > |
| > | | > | RadioButtons appearing in cell 1 have a GroupName of "TimeFrom"
| and
| > | | those
| > | | > | appearing in cell 2 have a GroupName of "TimeTo". The table
| appears
| > | | > | correctly (the code at the bottom of this post will generate it
| for
| > | you
| > | | if
| > | | > | you create yourself a Table with ID "TSTable".
| > | | > |
| > | | > | My problem, for those of you falling asleep by now, is that I
| > haven't
| > | | the
| > | | > | faintest idea of how to retrieve the "TimeFrom" and "TimeTo"
| > selected
| > | | > | values. I can put a kludge together that will use
| Request.Form(...)
| > | but
| > | | I
| > | | > | was rather hoping that there'd be a .NET way.
| > | | > |
| > | | > | Any help would be greatly appreciated.
| > | | > |
| > | | > | Cheers,
| > | | > | Tone
| > | | > |
| > | | > |
| > | | > | ' ---------- Begin Create Table Code ----------
| > | | > | Dim CurTime As New DateTime(Now.Year, Now.Month, Now.Day, 0, 0,
0)
| > | | > |
| > | | > | For i As Integer = 0 To 240 ' 24 hours in 240 six-minute (1/10
hr)
| > | | > | increments
| > | | > |
| > | | > | Dim Row As New TableRow
| > | | > | Dim CellFrom As New TableCell
| > | | > | Dim CellTo As New TableCell
| > | | > | Dim CellJob As New TableCell
| > | | > |
| > | | > | CellFrom.Width = Unit.Pixel(60)
| > | | > | CellTo.Width = Unit.Pixel(60)
| > | | > |
| > | | > | ' Create a radio button control which will select the From
| > time...
| > | | > | Dim RadioFrom As New RadioButton
| > | | > | RadioFrom.GroupName = "TimeFrom"
| > | | > | RadioFrom.EnableViewState = True
| > | | > | RadioFrom.Text = CurTime.AddMinutes(i * 6).ToShortTimeString
| > | | > |
| > | | > | ' ...then add it to the "From" cell we just created
| > | | > | CellFrom.Controls.Add(RadioFrom)
| > | | > |
| > | | > | ' And the same for selecting the To time...
| > | | > | Dim RadioTo As New RadioButton
| > | | > | RadioTo.GroupName = "TimeTo"
| > | | > | RadioTo.EnableViewState = True
| > | | > | RadioTo.Text = CurTime.AddMinutes(i * 6).ToShortTimeString
| > | | > |
| > | | > | ' ...then add it to the "To" cell
| > | | > | CellTo.Controls.Add(RadioTo)
| > | | > |
| > | | > | With Row.Cells
| > | | > | .Add(CellFrom)
| > | | > | .Add(CellTo)
| > | | > | .Add(CellJob)
| > | | > | End With
| > | | > |
| > | | > | RadioFrom.Dispose()
| > | | > | RadioTo.Dispose()
| > | | > |
| > | | > | CellFrom.Dispose()
| > | | > | CellTo.Dispose()
| > | | > | CellJob.Dispose()
| > | | > |
| > | | > | Row.Dispose()
| > | | > |
| > | | > | Next
| > | | > | ' ---------- End Create Table Code ----------
| > | | > |
| > | | > |
| > | | > |
| > | | >
| > | |
| > | |
| > | |
| > |
| >
|
|
|

 
Reply With Quote
 
Anthony Williams
Guest
Posts: n/a
 
      09-11-2003
Lewis,

In answer to your first question, yes and no. It does meet the requirements
in some ways (in that I can get the values specified) but it doesn't allow
me to get the name of the control that was selected using code behind
techniques - as I mentioned in my previous post, I'd like to be able to
build a function which would return a reference to the RadioButton control
which has a specified GroupName and is checked.

Is there a way of iterating through each of the controls (of a given type)
in the user control, page or whatever container?

Cheers,
Anthony

"Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Anthony,
>
> Does the solution in my prior post meet your requirements?
>
> It's possible to actually get the selected value by group name. But we

need
> to set the value attribution for every RadioButton. For example:
>
> RadioFrom.Attributes .Add("value",RadioFrom.Text); Then, we add these

radio
> buttons to the table using the method in your first post.
>
> Then, we can get the selected radio value using Request.Form["groupname
> "].ToString () in code behind.
>
> If we want to loop through each of the radio control in the User Control

or
> the page to check which radio button was checked using client side script,
> we can do that like this:
>
> 1. Set the id for each radio control, something like: radio1,
> radio2,**
> 2. Set the same "groupname" for each radio control.
> 3. The client side script may like this:
> <script language="javascript">
> function checkradios(){
> for(i=1;i<n;i++)
> if(document.all("radio"+i).checked)
> alert(document.all("radio"+i).value);
> }
> </script>
>
> Does this answer your question? Please let me know if you need more
> information.
>
> Best regards,
> Lewis
> This posting is provided "AS IS" with no warranties, and confers no

rights.
>
> --------------------
> | From: "Anthony Williams" <(E-Mail Removed)>
> | References: <(E-Mail Removed)>
> <(E-Mail Removed)>
> <(E-Mail Removed)>
> <(E-Mail Removed)>
> <(E-Mail Removed)>
> | Subject: Re: Retrieving checked RadioButton controls which were added to
> a Table control
> | Date: Wed, 10 Sep 2003 12:37:07 +0100
> | Lines: 353
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | Message-ID: <#H0Of$(E-Mail Removed)>
> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
> | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com

81.137.71.124
> | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
> | Xref: cpmsftngxa06.phx.gbl
> microsoft.public.dotnet.framework.aspnet.webcontro ls:14530
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
> |
> | Lewis,
> |
> | Sorry for the long answer, but basically, I thought it best to explain
> | exactly what I'm doing here.
> |
> | I have created a user control which contains a calendar control and this
> | free busy list which I'm creating. The date, as selected by the calendar
> | control sets a DateTime variable on the page to the current date. The
> | Free/Busy list then displays times from midnight on that day to midnight
> the
> | following day - a 24-hour block of 6-minute intervals.
> |
> | Ideally, I'd like to generate a table with 4 cells, like so:
> |
> | [Time] [Fr] [To] [Free/Busy]
> | 00:00 () ()
> | 00:06 () ()
> | 00:12 () ()
> | ..... () ()
> | 23:48 () ()
> | 23:54 () ()
> | 00:00 () ()
> |
> | Cell [Time] would contain the time, cells [Fr(om)] and [To] would

contain
> a
> | RadioButton control, the value of which would be the Date and Time

passed,
> | so that the end-user can select a "From" time and a "To" time. Cell
> | [Free/Busy] just contains information which is returned by a stored
> | procedure, which is the source for the information.
> |
> | So, my questions are:
> |
> | 1.
> | Since I have set all of the radiobutton controls to have the same
> GroupName
> | (either "TimeFrom" or "TimeTo") is it possible to find out the control
> name
> | of the radiobutton checked in each group - a function that you could

pass
> | the GroupName to which would return either the name of the checked
> | radiobutton control (great) or the value of the checked radiobutton
> control
> | (even better).
> |
> | Even if a function has to be written (I'm thinking something along the
> lines
> | of CheckedRadioButton(ByVal GroupName As String) As RadioButton) it's

got
> to
> | be better than the current state of affairs ) Any help you can offer

in
> | terms of writing such a function would be greatly appreciated - I

presume
> it
> | would have something to do with looping through each of the controls in
> the
> | User Control or the page with the GroupName as given, and then checking

to
> | see if ThatRadioButton.Checked is True...
> |
> | (PS - something like that should be added to the next point release, or
> | definately ASP.NET v2.0)
> |
> | 2.
> | Failing that, is there a way of creating a radiobutton list, and then
> taking
> | the rows that are generated by said radiobutton list, and adding them to

a
> | table that already exists - either a System.Web.UI.WebControls.Table or

a
> | System.Web.UI.HtmlControls.HtmlTable - and still be able to query the
> | RadioButtonList.SelectedValue value?
> |
> | 3.
> | Failing both of the above, what would you suggest? )
> |
> |
> | Cheers Lewis,
> | Anth
> |
> |
> |
> | "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
> | news:(E-Mail Removed)...
> | > Hi Anthony,
> | >
> | > I need more information to resolve the questions mentioned in the last
> | > paragraph of your post.
> | >
> | > What do you mean about putting the generated radiobutton list into a
> | table?
> | > Do you mean you want to put a radiobuttonlist control to a TableCell,

or
> | do
> | > you mean you want to put each radio control in the radiobuttonlist to
> each
> | > TableCell of a Table column?
> | >
> | > Thanks a lot.
> | >
> | > Lewis
> | >
> | > --------------------
> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
> | > | From: (E-Mail Removed) (Lewis Wang [MSFT])
> | > | Organization: Microsoft
> | > | Date: Tue, 09 Sep 2003 15:08:10 GMT
> | > | Subject: Re: Retrieving checked RadioButton controls which were

added
> to
> | > a Table control
> | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
> | > | MIME-Version: 1.0
> | > | Content-Type: text/plain
> | > | Content-Transfer-Encoding: 7bit
> | > |
> | > | Hi Anthony,
> | > |
> | > | It's possible to actually get the selected value by group name. But

we
> | > need
> | > | to set the value attribution for every RadioButton. For example:
> | > |
> | > | RadioFrom.Attributes .Add("value",RadioFrom.Text);
> | > |
> | > | Then, we can get the selected value using Request.Form
> | > | ["TimeFrom"].ToString () in code behind.
> | > |
> | > | Hope this helps.
> | > |
> | > | Best regards,
> | > | Lewis
> | > | This posting is provided "AS IS" with no warranties, and confers no
> | > rights.
> | > |
> | > | --------------------
> | > | | From: "Anthony Williams" <(E-Mail Removed)>
> | > | | References: <(E-Mail Removed)>
> | > | <(E-Mail Removed)>
> | > | | Subject: Re: Retrieving checked RadioButton controls which were
> added
> | > to
> | > | a Table control
> | > | | Date: Tue, 9 Sep 2003 09:23:01 +0100
> | > | | Lines: 184
> | > | | X-Priority: 3
> | > | | X-MSMail-Priority: Normal
> | > | | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | > | | Message-ID: <(E-Mail Removed)>
> | > | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
> | > | | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com
> | > 81.137.71.124
> | > | | Path:

cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
> | > | | Xref: cpmsftngxa06.phx.gbl
> | > | microsoft.public.dotnet.framework.aspnet.webcontro ls:14497
> | > | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
> | > | |
> | > | | Lewis,
> | > | |
> | > | | Thanks for the reply - not only did you manage to answer one
> question,
> | > but
> | > | | you also tackled another which I was about to post to a different
> | group
> | > -
> | > | | namely how do I manually populate a dataset - hehe. Thanks for the
> | > reply,
> | > | | but...
> | > | |
> | > | | Because I've already manually populated a table with radiobutton
> | > controls,
> | > | | I'm wondering whether or not it's possible to actually get the
> | selected
> | > | | value by group name - the reason I ask this specifically, is

because
> | > I've
> | > | | got a table with three columns - a radiobutton list won't allow me
> to
> | > keep
> | > | | my format in this way (will it?)
> | > | |
> | > | | Is there either a way to put the generated radiobutton list into a
> | table
> | > | | that already exists, or - possibly - add each of the radiobutton
> | > controls
> | > | | not only to the table, but also to a radiobutton list?
> | > | |
> | > | | Cheers,
> | > | | Anthony
> | > | |
> | > | |
> | > | | "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in

message
> | > | | news:(E-Mail Removed)...
> | > | | > Hi Anthony,
> | > | | >
> | > | | > You can put the 240 ShortTimeStrings in a DataSet/DataTable and
> bind
> | > it
> | > | to
> | > | | > a RadioButtonList. Then we can get the selected radio text by "
> | > | | > RadioButtonList1.SelectedItem.ToString ()". Here is a code

snippet
> | for
> | > | | > demonstration, you may modify it to meet your requirements.
> | > | | >
> | > | | > protected DataSet GetSource()
> | > | | > {
> | > | | > . .
> | > | | > if(Session["ds"]!=null)return (DataSet)Session["ds"];
> | > | | > DataSet ds=new DataSet();
> | > | | > DataTable newtable=new DataTable ();
> | > | | > DataColumn cc1 = new
> | > | DataColumn("From",Type.GetType("System.String"),"" );
> | > | | > DataColumn cc2 = new DataColumn("To",
> | > Type.GetType("System.String"),"");
> | > | | > DataColumn cc3 = new DataColumn("Job",
> | > | Type.GetType("System.String"),"");
> | > | | > newtable.Columns.Add(cc1);
> | > | | > newtable.Columns.Add(cc2);
> | > | | > newtable.Columns.Add(cc3);
> | > | | > for(int i=0; i<240;i++)
> | > | | > {
> | > | | > DataRow dr=newtable.NewRow ();
> | > | | > dr["From"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
> | > | | > dr["To"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
> | > | | > dr["Job"]="";
> | > | | > newtable.Rows .Add(dr);
> | > | | > }
> | > | | > ds.Tables .Add (newtable);
> | > | | > Session["ds"]=ds;
> | > | | >
> | > | | > return ds;
> | > | | > }
> | > | | >
> | > | | > private void Page_Load(object sender, System.EventArgs e)
> | > | | > {
> | > | | > if(!this.IsPostBack)
> | > | | > {
> | > | | > DataSet ds=GetSource();
> | > | | > RadioButtonList1.DataSource =ds;
> | > | | > RadioButtonList1.DataTextField ="From";
> | > | | > RadioButtonList1.DataBind ();
> | > | | > . . .
> | > | | > }
> | > | | > }
> | > | | >
> | > | | > private void Button1_Click(object sender, System.EventArgs e)
> | > | | > {
> | > | | > Response.Write ("From:" + RadioButtonList1.SelectedItem.ToString
> | ());
> | > | | > . . .
> | > | | > }
> | > | | >
> | > | | > Does this answer your question? Please let me know if you need
> more
> | > | | > information. Thanks.
> | > | | >
> | > | | > Best regards,
> | > | | > Lewis
> | > | | > This posting is provided "AS IS" with no warranties, and confers
> no
> | > | | rights.
> | > | | >
> | > | | > --------------------
> | > | | > | From: "Anthony Williams" <(E-Mail Removed)>
> | > | | > | Subject: Retrieving checked RadioButton controls which were
> added
> | > to a
> | > | | > Table control
> | > | | > | Date: Mon, 8 Sep 2003 12:28:26 +0100
> | > | | > | Lines: 73
> | > | | > | X-Priority: 3
> | > | | > | X-MSMail-Priority: Normal
> | > | | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | > | | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | > | | > | Message-ID: <(E-Mail Removed)>
> | > | | > | Newsgroups:

microsoft.public.dotnet.framework.aspnet.webcontro ls
> | > | | > | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com
> | > | | 81.137.71.124
> | > | | > | Path:
> | cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
> | > | | > | Xref: cpmsftngxa06.phx.gbl
> | > | | > microsoft.public.dotnet.framework.aspnet.webcontro ls:14469
> | > | | > | X-Tomcat-NG:
> microsoft.public.dotnet.framework.aspnet.webcontro ls
> | > | | > |
> | > | | > | Hi gang,
> | > | | > |
> | > | | > | I've created and populated a huge table, with 240 rows, with
> three
> | > | cells
> | > | | > per
> | > | | > | row. There are 240 RadioButton controls for "TimeFrom", and

240
> | > | | > RadioButton
> | > | | > | controls for "TimeTo".
> | > | | > |
> | > | | > | RadioButtons appearing in cell 1 have a GroupName of

"TimeFrom"
> | and
> | > | | those
> | > | | > | appearing in cell 2 have a GroupName of "TimeTo". The table
> | appears
> | > | | > | correctly (the code at the bottom of this post will generate

it
> | for
> | > | you
> | > | | if
> | > | | > | you create yourself a Table with ID "TSTable".
> | > | | > |
> | > | | > | My problem, for those of you falling asleep by now, is that I
> | > haven't
> | > | | the
> | > | | > | faintest idea of how to retrieve the "TimeFrom" and "TimeTo"
> | > selected
> | > | | > | values. I can put a kludge together that will use
> | Request.Form(...)
> | > | but
> | > | | I
> | > | | > | was rather hoping that there'd be a .NET way.
> | > | | > |
> | > | | > | Any help would be greatly appreciated.
> | > | | > |
> | > | | > | Cheers,
> | > | | > | Tone
> | > | | > |
> | > | | > |
> | > | | > | ' ---------- Begin Create Table Code ----------
> | > | | > | Dim CurTime As New DateTime(Now.Year, Now.Month, Now.Day, 0,

0,
> 0)
> | > | | > |
> | > | | > | For i As Integer = 0 To 240 ' 24 hours in 240 six-minute (1/10
> hr)
> | > | | > | increments
> | > | | > |
> | > | | > | Dim Row As New TableRow
> | > | | > | Dim CellFrom As New TableCell
> | > | | > | Dim CellTo As New TableCell
> | > | | > | Dim CellJob As New TableCell
> | > | | > |
> | > | | > | CellFrom.Width = Unit.Pixel(60)
> | > | | > | CellTo.Width = Unit.Pixel(60)
> | > | | > |
> | > | | > | ' Create a radio button control which will select the From
> | > time...
> | > | | > | Dim RadioFrom As New RadioButton
> | > | | > | RadioFrom.GroupName = "TimeFrom"
> | > | | > | RadioFrom.EnableViewState = True
> | > | | > | RadioFrom.Text = CurTime.AddMinutes(i *

6).ToShortTimeString
> | > | | > |
> | > | | > | ' ...then add it to the "From" cell we just created
> | > | | > | CellFrom.Controls.Add(RadioFrom)
> | > | | > |
> | > | | > | ' And the same for selecting the To time...
> | > | | > | Dim RadioTo As New RadioButton
> | > | | > | RadioTo.GroupName = "TimeTo"
> | > | | > | RadioTo.EnableViewState = True
> | > | | > | RadioTo.Text = CurTime.AddMinutes(i * 6).ToShortTimeString
> | > | | > |
> | > | | > | ' ...then add it to the "To" cell
> | > | | > | CellTo.Controls.Add(RadioTo)
> | > | | > |
> | > | | > | With Row.Cells
> | > | | > | .Add(CellFrom)
> | > | | > | .Add(CellTo)
> | > | | > | .Add(CellJob)
> | > | | > | End With
> | > | | > |
> | > | | > | RadioFrom.Dispose()
> | > | | > | RadioTo.Dispose()
> | > | | > |
> | > | | > | CellFrom.Dispose()
> | > | | > | CellTo.Dispose()
> | > | | > | CellJob.Dispose()
> | > | | > |
> | > | | > | Row.Dispose()
> | > | | > |
> | > | | > | Next
> | > | | > | ' ---------- End Create Table Code ----------
> | > | | > |
> | > | | > |
> | > | | > |
> | > | | >
> | > | |
> | > | |
> | > | |
> | > |
> | >
> |
> |
> |
>



 
Reply With Quote
 
Felix Wu [MSFT]
Guest
Posts: n/a
 
      09-15-2003
Hi Anthony ,

This is actually a known issue that radio buttons in the ItemTemplate are
not mutually exclusive:

BUG: Radio Buttons Are Not Mutually Exclusive When Used in a Repeater
Server Control
http://support.microsoft.com/?scid=kb;en-us;Q316495

We can workaround this by using either client side script or handling the
CheckedChanged event on the server side. Here is the way to handle the
CheckedChanged event. Please note that this method requires more postback
than client side script does:

1. We can use a Datagrid's to display the rows as Lewis suggested.

2. Create a ItemTemplate column and add a RadioButton to the column. Bind
the RadioButton appropriately.

3. Open the ASPX view of the page, add "OnCheckedChanged" attribute to the
<asp:RadioButton> element, and make it point to a public handler method
defined in the code behind file. Here is a code snippet for example:

In ASPX file
==========
<asp:TemplateColumn HeaderText="RadioCol">
<ItemTemplate>
<asp:RadioButton id="RadioButton4" AutoPostBack="True"
OnCheckedChanged="RadioButton4_CheckedChanged" runat="server"
GroupName="DtFrom"></asp:RadioButton>
</ItemTemplate>
</asp:TemplateColumn>


In the code behind file
===================
public void RadioButton4_CheckedChanged(object sender, System.EventArgs e)
{
RadioButton rb=(RadioButton)sender;
Response.Write(rb.ClientID.ToString()); //This line is just for test
purpose.
for (int i =0 ; i <DataGrid1.Items.Count; i++)
{
((RadioButton)DataGrid1.Items[i].Controls[0].Controls[1]).Checked= false;
}
// check the selected radio button
rb.Checked= true;
}

To get the selected RadioButton when you submit the page, I think you can
try the FindCotrol method.

Regards,

Felix Wu
=======
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "Anthony Williams" <(E-Mail Removed)>
>References: <(E-Mail Removed)>

<(E-Mail Removed)>
<(E-Mail Removed)>
<(E-Mail Removed)>
<(E-Mail Removed)>
<#H0Of$(E-Mail Removed)>
<(E-Mail Removed)>
>Subject: Re: Retrieving checked RadioButton controls which were added to a

Table control
>Date: Thu, 11 Sep 2003 12:31:57 +0100
>Lines: 483
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>Message-ID: <#(E-Mail Removed)>
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
>NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com 81.137.71.124
>Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
>Xref: cpmsftngxa06.phx.gbl

microsoft.public.dotnet.framework.aspnet.webcontro ls:14563
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
>
>Lewis,
>
>In answer to your first question, yes and no. It does meet the requirements
>in some ways (in that I can get the values specified) but it doesn't allow
>me to get the name of the control that was selected using code behind
>techniques - as I mentioned in my previous post, I'd like to be able to
>build a function which would return a reference to the RadioButton control
>which has a specified GroupName and is checked.
>
>Is there a way of iterating through each of the controls (of a given type)
>in the user control, page or whatever container?
>
>Cheers,
>Anthony
>
>"Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> Hi Anthony,
>>
>> Does the solution in my prior post meet your requirements?
>>
>> It's possible to actually get the selected value by group name. But we

>need
>> to set the value attribution for every RadioButton. For example:
>>
>> RadioFrom.Attributes .Add("value",RadioFrom.Text); Then, we add these

>radio
>> buttons to the table using the method in your first post.
>>
>> Then, we can get the selected radio value using Request.Form["groupname
>> "].ToString () in code behind.
>>
>> If we want to loop through each of the radio control in the User Control

>or
>> the page to check which radio button was checked using client side

script,
>> we can do that like this:
>>
>> 1. Set the id for each radio control, something like: radio1,
>> radio2,**
>> 2. Set the same "groupname" for each radio control.
>> 3. The client side script may like this:
>> <script language="javascript">
>> function checkradios(){
>> for(i=1;i<n;i++)
>> if(document.all("radio"+i).checked)
>> alert(document.all("radio"+i).value);
>> }
>> </script>
>>
>> Does this answer your question? Please let me know if you need more
>> information.
>>
>> Best regards,
>> Lewis
>> This posting is provided "AS IS" with no warranties, and confers no

>rights.
>>
>> --------------------
>> | From: "Anthony Williams" <(E-Mail Removed)>
>> | References: <(E-Mail Removed)>
>> <(E-Mail Removed)>
>> <(E-Mail Removed)>
>> <(E-Mail Removed)>
>> <(E-Mail Removed)>
>> | Subject: Re: Retrieving checked RadioButton controls which were added

to
>> a Table control
>> | Date: Wed, 10 Sep 2003 12:37:07 +0100
>> | Lines: 353
>> | X-Priority: 3
>> | X-MSMail-Priority: Normal
>> | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>> | Message-ID: <#H0Of$(E-Mail Removed)>
>> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
>> | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com

>81.137.71.124
>> | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
>> | Xref: cpmsftngxa06.phx.gbl
>> microsoft.public.dotnet.framework.aspnet.webcontro ls:14530
>> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
>> |
>> | Lewis,
>> |
>> | Sorry for the long answer, but basically, I thought it best to explain
>> | exactly what I'm doing here.
>> |
>> | I have created a user control which contains a calendar control and

this
>> | free busy list which I'm creating. The date, as selected by the

calendar
>> | control sets a DateTime variable on the page to the current date. The
>> | Free/Busy list then displays times from midnight on that day to

midnight
>> the
>> | following day - a 24-hour block of 6-minute intervals.
>> |
>> | Ideally, I'd like to generate a table with 4 cells, like so:
>> |
>> | [Time] [Fr] [To] [Free/Busy]
>> | 00:00 () ()
>> | 00:06 () ()
>> | 00:12 () ()
>> | ..... () ()
>> | 23:48 () ()
>> | 23:54 () ()
>> | 00:00 () ()
>> |
>> | Cell [Time] would contain the time, cells [Fr(om)] and [To] would

>contain
>> a
>> | RadioButton control, the value of which would be the Date and Time

>passed,
>> | so that the end-user can select a "From" time and a "To" time. Cell
>> | [Free/Busy] just contains information which is returned by a stored
>> | procedure, which is the source for the information.
>> |
>> | So, my questions are:
>> |
>> | 1.
>> | Since I have set all of the radiobutton controls to have the same
>> GroupName
>> | (either "TimeFrom" or "TimeTo") is it possible to find out the control
>> name
>> | of the radiobutton checked in each group - a function that you could

>pass
>> | the GroupName to which would return either the name of the checked
>> | radiobutton control (great) or the value of the checked radiobutton
>> control
>> | (even better).
>> |
>> | Even if a function has to be written (I'm thinking something along the
>> lines
>> | of CheckedRadioButton(ByVal GroupName As String) As RadioButton) it's

>got
>> to
>> | be better than the current state of affairs ) Any help you can offer

>in
>> | terms of writing such a function would be greatly appreciated - I

>presume
>> it
>> | would have something to do with looping through each of the controls in
>> the
>> | User Control or the page with the GroupName as given, and then checking

>to
>> | see if ThatRadioButton.Checked is True...
>> |
>> | (PS - something like that should be added to the next point release, or
>> | definately ASP.NET v2.0)
>> |
>> | 2.
>> | Failing that, is there a way of creating a radiobutton list, and then
>> taking
>> | the rows that are generated by said radiobutton list, and adding them

to
>a
>> | table that already exists - either a System.Web.UI.WebControls.Table or

>a
>> | System.Web.UI.HtmlControls.HtmlTable - and still be able to query the
>> | RadioButtonList.SelectedValue value?
>> |
>> | 3.
>> | Failing both of the above, what would you suggest? )
>> |
>> |
>> | Cheers Lewis,
>> | Anth
>> |
>> |
>> |
>> | "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
>> | news:(E-Mail Removed)...
>> | > Hi Anthony,
>> | >
>> | > I need more information to resolve the questions mentioned in the

last
>> | > paragraph of your post.
>> | >
>> | > What do you mean about putting the generated radiobutton list into a
>> | table?
>> | > Do you mean you want to put a radiobuttonlist control to a TableCell,

>or
>> | do
>> | > you mean you want to put each radio control in the radiobuttonlist to
>> each
>> | > TableCell of a Table column?
>> | >
>> | > Thanks a lot.
>> | >
>> | > Lewis
>> | >
>> | > --------------------
>> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
>> | > | From: (E-Mail Removed) (Lewis Wang [MSFT])
>> | > | Organization: Microsoft
>> | > | Date: Tue, 09 Sep 2003 15:08:10 GMT
>> | > | Subject: Re: Retrieving checked RadioButton controls which were

>added
>> to
>> | > a Table control
>> | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
>> | > | MIME-Version: 1.0
>> | > | Content-Type: text/plain
>> | > | Content-Transfer-Encoding: 7bit
>> | > |
>> | > | Hi Anthony,
>> | > |
>> | > | It's possible to actually get the selected value by group name. But

>we
>> | > need
>> | > | to set the value attribution for every RadioButton. For example:
>> | > |
>> | > | RadioFrom.Attributes .Add("value",RadioFrom.Text);
>> | > |
>> | > | Then, we can get the selected value using Request.Form
>> | > | ["TimeFrom"].ToString () in code behind.
>> | > |
>> | > | Hope this helps.
>> | > |
>> | > | Best regards,
>> | > | Lewis
>> | > | This posting is provided "AS IS" with no warranties, and confers no
>> | > rights.
>> | > |
>> | > | --------------------
>> | > | | From: "Anthony Williams" <(E-Mail Removed)>
>> | > | | References: <(E-Mail Removed)>
>> | > | <(E-Mail Removed)>
>> | > | | Subject: Re: Retrieving checked RadioButton controls which were
>> added
>> | > to
>> | > | a Table control
>> | > | | Date: Tue, 9 Sep 2003 09:23:01 +0100
>> | > | | Lines: 184
>> | > | | X-Priority: 3
>> | > | | X-MSMail-Priority: Normal
>> | > | | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>> | > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>> | > | | Message-ID: <(E-Mail Removed)>
>> | > | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
>> | > | | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com
>> | > 81.137.71.124
>> | > | | Path:

>cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
>> | > | | Xref: cpmsftngxa06.phx.gbl
>> | > | microsoft.public.dotnet.framework.aspnet.webcontro ls:14497
>> | > | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
>> | > | |
>> | > | | Lewis,
>> | > | |
>> | > | | Thanks for the reply - not only did you manage to answer one
>> question,
>> | > but
>> | > | | you also tackled another which I was about to post to a different
>> | group
>> | > -
>> | > | | namely how do I manually populate a dataset - hehe. Thanks for

the
>> | > reply,
>> | > | | but...
>> | > | |
>> | > | | Because I've already manually populated a table with radiobutton
>> | > controls,
>> | > | | I'm wondering whether or not it's possible to actually get the
>> | selected
>> | > | | value by group name - the reason I ask this specifically, is

>because
>> | > I've
>> | > | | got a table with three columns - a radiobutton list won't allow

me
>> to
>> | > keep
>> | > | | my format in this way (will it?)
>> | > | |
>> | > | | Is there either a way to put the generated radiobutton list into

a
>> | table
>> | > | | that already exists, or - possibly - add each of the radiobutton
>> | > controls
>> | > | | not only to the table, but also to a radiobutton list?
>> | > | |
>> | > | | Cheers,
>> | > | | Anthony
>> | > | |
>> | > | |
>> | > | | "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in

>message
>> | > | | news:(E-Mail Removed)...
>> | > | | > Hi Anthony,
>> | > | | >
>> | > | | > You can put the 240 ShortTimeStrings in a DataSet/DataTable and
>> bind
>> | > it
>> | > | to
>> | > | | > a RadioButtonList. Then we can get the selected radio text by "
>> | > | | > RadioButtonList1.SelectedItem.ToString ()". Here is a code

>snippet
>> | for
>> | > | | > demonstration, you may modify it to meet your requirements.
>> | > | | >
>> | > | | > protected DataSet GetSource()
>> | > | | > {
>> | > | | > . .
>> | > | | > if(Session["ds"]!=null)return (DataSet)Session["ds"];
>> | > | | > DataSet ds=new DataSet();
>> | > | | > DataTable newtable=new DataTable ();
>> | > | | > DataColumn cc1 = new
>> | > | DataColumn("From",Type.GetType("System.String"),"" );
>> | > | | > DataColumn cc2 = new DataColumn("To",
>> | > Type.GetType("System.String"),"");
>> | > | | > DataColumn cc3 = new DataColumn("Job",
>> | > | Type.GetType("System.String"),"");
>> | > | | > newtable.Columns.Add(cc1);
>> | > | | > newtable.Columns.Add(cc2);
>> | > | | > newtable.Columns.Add(cc3);
>> | > | | > for(int i=0; i<240;i++)
>> | > | | > {
>> | > | | > DataRow dr=newtable.NewRow ();
>> | > | | > dr["From"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
>> | > | | > dr["To"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
>> | > | | > dr["Job"]="";
>> | > | | > newtable.Rows .Add(dr);
>> | > | | > }
>> | > | | > ds.Tables .Add (newtable);
>> | > | | > Session["ds"]=ds;
>> | > | | >
>> | > | | > return ds;
>> | > | | > }
>> | > | | >
>> | > | | > private void Page_Load(object sender, System.EventArgs e)
>> | > | | > {
>> | > | | > if(!this.IsPostBack)
>> | > | | > {
>> | > | | > DataSet ds=GetSource();
>> | > | | > RadioButtonList1.DataSource =ds;
>> | > | | > RadioButtonList1.DataTextField ="From";
>> | > | | > RadioButtonList1.DataBind ();
>> | > | | > . . .
>> | > | | > }
>> | > | | > }
>> | > | | >
>> | > | | > private void Button1_Click(object sender, System.EventArgs e)
>> | > | | > {
>> | > | | > Response.Write ("From:" +

RadioButtonList1.SelectedItem.ToString
>> | ());
>> | > | | > . . .
>> | > | | > }
>> | > | | >
>> | > | | > Does this answer your question? Please let me know if you need
>> more
>> | > | | > information. Thanks.
>> | > | | >
>> | > | | > Best regards,
>> | > | | > Lewis
>> | > | | > This posting is provided "AS IS" with no warranties, and

confers
>> no
>> | > | | rights.
>> | > | | >
>> | > | | > --------------------
>> | > | | > | From: "Anthony Williams" <(E-Mail Removed)>
>> | > | | > | Subject: Retrieving checked RadioButton controls which were
>> added
>> | > to a
>> | > | | > Table control
>> | > | | > | Date: Mon, 8 Sep 2003 12:28:26 +0100
>> | > | | > | Lines: 73
>> | > | | > | X-Priority: 3
>> | > | | > | X-MSMail-Priority: Normal
>> | > | | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>> | > | | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>> | > | | > | Message-ID: <(E-Mail Removed)>
>> | > | | > | Newsgroups:

>microsoft.public.dotnet.framework.aspnet.webcontr ols
>> | > | | > | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com
>> | > | | 81.137.71.124
>> | > | | > | Path:
>> | cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
>> | > | | > | Xref: cpmsftngxa06.phx.gbl
>> | > | | > microsoft.public.dotnet.framework.aspnet.webcontro ls:14469
>> | > | | > | X-Tomcat-NG:
>> microsoft.public.dotnet.framework.aspnet.webcontro ls
>> | > | | > |
>> | > | | > | Hi gang,
>> | > | | > |
>> | > | | > | I've created and populated a huge table, with 240 rows, with
>> three
>> | > | cells
>> | > | | > per
>> | > | | > | row. There are 240 RadioButton controls for "TimeFrom", and

>240
>> | > | | > RadioButton
>> | > | | > | controls for "TimeTo".
>> | > | | > |
>> | > | | > | RadioButtons appearing in cell 1 have a GroupName of

>"TimeFrom"
>> | and
>> | > | | those
>> | > | | > | appearing in cell 2 have a GroupName of "TimeTo". The table
>> | appears
>> | > | | > | correctly (the code at the bottom of this post will generate

>it
>> | for
>> | > | you
>> | > | | if
>> | > | | > | you create yourself a Table with ID "TSTable".
>> | > | | > |
>> | > | | > | My problem, for those of you falling asleep by now, is that I
>> | > haven't
>> | > | | the
>> | > | | > | faintest idea of how to retrieve the "TimeFrom" and "TimeTo"
>> | > selected
>> | > | | > | values. I can put a kludge together that will use
>> | Request.Form(...)
>> | > | but
>> | > | | I
>> | > | | > | was rather hoping that there'd be a .NET way.
>> | > | | > |
>> | > | | > | Any help would be greatly appreciated.
>> | > | | > |
>> | > | | > | Cheers,
>> | > | | > | Tone
>> | > | | > |
>> | > | | > |
>> | > | | > | ' ---------- Begin Create Table Code ----------
>> | > | | > | Dim CurTime As New DateTime(Now.Year, Now.Month, Now.Day, 0,

>0,
>> 0)
>> | > | | > |
>> | > | | > | For i As Integer = 0 To 240 ' 24 hours in 240 six-minute

(1/10
>> hr)
>> | > | | > | increments
>> | > | | > |
>> | > | | > | Dim Row As New TableRow
>> | > | | > | Dim CellFrom As New TableCell
>> | > | | > | Dim CellTo As New TableCell
>> | > | | > | Dim CellJob As New TableCell
>> | > | | > |
>> | > | | > | CellFrom.Width = Unit.Pixel(60)
>> | > | | > | CellTo.Width = Unit.Pixel(60)
>> | > | | > |
>> | > | | > | ' Create a radio button control which will select the

From
>> | > time...
>> | > | | > | Dim RadioFrom As New RadioButton
>> | > | | > | RadioFrom.GroupName = "TimeFrom"
>> | > | | > | RadioFrom.EnableViewState = True
>> | > | | > | RadioFrom.Text = CurTime.AddMinutes(i *

>6).ToShortTimeString
>> | > | | > |
>> | > | | > | ' ...then add it to the "From" cell we just created
>> | > | | > | CellFrom.Controls.Add(RadioFrom)
>> | > | | > |
>> | > | | > | ' And the same for selecting the To time...
>> | > | | > | Dim RadioTo As New RadioButton
>> | > | | > | RadioTo.GroupName = "TimeTo"
>> | > | | > | RadioTo.EnableViewState = True
>> | > | | > | RadioTo.Text = CurTime.AddMinutes(i *

6).ToShortTimeString
>> | > | | > |
>> | > | | > | ' ...then add it to the "To" cell
>> | > | | > | CellTo.Controls.Add(RadioTo)
>> | > | | > |
>> | > | | > | With Row.Cells
>> | > | | > | .Add(CellFrom)
>> | > | | > | .Add(CellTo)
>> | > | | > | .Add(CellJob)
>> | > | | > | End With
>> | > | | > |
>> | > | | > | RadioFrom.Dispose()
>> | > | | > | RadioTo.Dispose()
>> | > | | > |
>> | > | | > | CellFrom.Dispose()
>> | > | | > | CellTo.Dispose()
>> | > | | > | CellJob.Dispose()
>> | > | | > |
>> | > | | > | Row.Dispose()
>> | > | | > |
>> | > | | > | Next
>> | > | | > | ' ---------- End Create Table Code ----------
>> | > | | > |
>> | > | | > |
>> | > | | > |
>> | > | | >
>> | > | |
>> | > | |
>> | > | |
>> | > |
>> | >
>> |
>> |
>> |
>>

>
>
>


 
Reply With Quote
 
Felix Wu [MSFT]
Guest
Posts: n/a
 
      09-16-2003
Hi Anthony ,

You could also handle the submit button's server-side click event and
iterate the rows of the table to find out the selected radio button.

Regards,

Felix Wu
=======
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>X-Tomcat-ID: 10015629
>References: <(E-Mail Removed)>

<(E-Mail Removed)>
<(E-Mail Removed)>
<(E-Mail Removed)>
<(E-Mail Removed)>
<#H0Of$(E-Mail Removed)>
<(E-Mail Removed)>
<#(E-Mail Removed)>
>MIME-Version: 1.0
>Content-Type: text/plain
>Content-Transfer-Encoding: 7bit
>From: (E-Mail Removed) (Felix Wu [MSFT])
>Organization: Microsoft
>Date: Mon, 15 Sep 2003 07:22:46 GMT
>Subject: Re: Retrieving checked RadioButton controls which were added to a

Table control
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
>Message-ID: <#72#(E-Mail Removed)>
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
>Lines: 508
>Path: cpmsftngxa07.phx.gbl
>Xref: cpmsftngxa07.phx.gbl

microsoft.public.dotnet.framework.aspnet.webcontro ls:14596
>NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
>
>Hi Anthony ,
>
>This is actually a known issue that radio buttons in the ItemTemplate are
>not mutually exclusive:
>
>BUG: Radio Buttons Are Not Mutually Exclusive When Used in a Repeater
>Server Control
>http://support.microsoft.com/?scid=kb;en-us;Q316495
>
>We can workaround this by using either client side script or handling the
>CheckedChanged event on the server side. Here is the way to handle the
>CheckedChanged event. Please note that this method requires more postback
>than client side script does:
>
>1. We can use a Datagrid's to display the rows as Lewis suggested.
>
>2. Create a ItemTemplate column and add a RadioButton to the column. Bind
>the RadioButton appropriately.
>
>3. Open the ASPX view of the page, add "OnCheckedChanged" attribute to the
><asp:RadioButton> element, and make it point to a public handler method
>defined in the code behind file. Here is a code snippet for example:
>
>In ASPX file
>==========
><asp:TemplateColumn HeaderText="RadioCol">
> <ItemTemplate>
> <asp:RadioButton id="RadioButton4" AutoPostBack="True"
>OnCheckedChanged="RadioButton4_CheckedChanged" runat="server"
>GroupName="DtFrom"></asp:RadioButton>
> </ItemTemplate>
></asp:TemplateColumn>
>
>
>In the code behind file
>===================
>public void RadioButton4_CheckedChanged(object sender, System.EventArgs e)
>{
> RadioButton rb=(RadioButton)sender;
> Response.Write(rb.ClientID.ToString()); //This line is just for test
>purpose.
> for (int i =0 ; i <DataGrid1.Items.Count; i++)
> {
> ((RadioButton)DataGrid1.Items[i].Controls[0].Controls[1]).Checked= false;
> }
> // check the selected radio button
> rb.Checked= true;
>}
>
>To get the selected RadioButton when you submit the page, I think you can
>try the FindCotrol method.
>
>Regards,
>
>Felix Wu
>=======
>This posting is provided "AS IS" with no warranties, and confers no rights.
>
>--------------------
>>From: "Anthony Williams" <(E-Mail Removed)>
>>References: <(E-Mail Removed)>

><(E-Mail Removed)>
><(E-Mail Removed)>
><(E-Mail Removed)>
><(E-Mail Removed)>
><#H0Of$(E-Mail Removed)>
><(E-Mail Removed)>
>>Subject: Re: Retrieving checked RadioButton controls which were added to

a
>Table control
>>Date: Thu, 11 Sep 2003 12:31:57 +0100
>>Lines: 483
>>X-Priority: 3
>>X-MSMail-Priority: Normal
>>X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>>Message-ID: <#(E-Mail Removed)>
>>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
>>NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com 81.137.71.124
>>Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
>>Xref: cpmsftngxa06.phx.gbl

>microsoft.public.dotnet.framework.aspnet.webcontr ols:14563
>>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
>>
>>Lewis,
>>
>>In answer to your first question, yes and no. It does meet the

requirements
>>in some ways (in that I can get the values specified) but it doesn't allow
>>me to get the name of the control that was selected using code behind
>>techniques - as I mentioned in my previous post, I'd like to be able to
>>build a function which would return a reference to the RadioButton control
>>which has a specified GroupName and is checked.
>>
>>Is there a way of iterating through each of the controls (of a given type)
>>in the user control, page or whatever container?
>>
>>Cheers,
>>Anthony
>>
>>"Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
>>news:(E-Mail Removed)...
>>> Hi Anthony,
>>>
>>> Does the solution in my prior post meet your requirements?
>>>
>>> It's possible to actually get the selected value by group name. But we

>>need
>>> to set the value attribution for every RadioButton. For example:
>>>
>>> RadioFrom.Attributes .Add("value",RadioFrom.Text); Then, we add these

>>radio
>>> buttons to the table using the method in your first post.
>>>
>>> Then, we can get the selected radio value using Request.Form["groupname
>>> "].ToString () in code behind.
>>>
>>> If we want to loop through each of the radio control in the User Control

>>or
>>> the page to check which radio button was checked using client side

>script,
>>> we can do that like this:
>>>
>>> 1. Set the id for each radio control, something like: radio1,
>>> radio2,**
>>> 2. Set the same "groupname" for each radio control.
>>> 3. The client side script may like this:
>>> <script language="javascript">
>>> function checkradios(){
>>> for(i=1;i<n;i++)
>>> if(document.all("radio"+i).checked)
>>> alert(document.all("radio"+i).value);
>>> }
>>> </script>
>>>
>>> Does this answer your question? Please let me know if you need more
>>> information.
>>>
>>> Best regards,
>>> Lewis
>>> This posting is provided "AS IS" with no warranties, and confers no

>>rights.
>>>
>>> --------------------
>>> | From: "Anthony Williams" <(E-Mail Removed)>
>>> | References: <(E-Mail Removed)>
>>> <(E-Mail Removed)>
>>> <(E-Mail Removed)>
>>> <(E-Mail Removed)>
>>> <(E-Mail Removed)>
>>> | Subject: Re: Retrieving checked RadioButton controls which were added

>to
>>> a Table control
>>> | Date: Wed, 10 Sep 2003 12:37:07 +0100
>>> | Lines: 353
>>> | X-Priority: 3
>>> | X-MSMail-Priority: Normal
>>> | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>>> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>>> | Message-ID: <#H0Of$(E-Mail Removed)>
>>> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
>>> | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com

>>81.137.71.124
>>> | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
>>> | Xref: cpmsftngxa06.phx.gbl
>>> microsoft.public.dotnet.framework.aspnet.webcontro ls:14530
>>> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
>>> |
>>> | Lewis,
>>> |
>>> | Sorry for the long answer, but basically, I thought it best to explain
>>> | exactly what I'm doing here.
>>> |
>>> | I have created a user control which contains a calendar control and

>this
>>> | free busy list which I'm creating. The date, as selected by the

>calendar
>>> | control sets a DateTime variable on the page to the current date. The
>>> | Free/Busy list then displays times from midnight on that day to

>midnight
>>> the
>>> | following day - a 24-hour block of 6-minute intervals.
>>> |
>>> | Ideally, I'd like to generate a table with 4 cells, like so:
>>> |
>>> | [Time] [Fr] [To] [Free/Busy]
>>> | 00:00 () ()
>>> | 00:06 () ()
>>> | 00:12 () ()
>>> | ..... () ()
>>> | 23:48 () ()
>>> | 23:54 () ()
>>> | 00:00 () ()
>>> |
>>> | Cell [Time] would contain the time, cells [Fr(om)] and [To] would

>>contain
>>> a
>>> | RadioButton control, the value of which would be the Date and Time

>>passed,
>>> | so that the end-user can select a "From" time and a "To" time. Cell
>>> | [Free/Busy] just contains information which is returned by a stored
>>> | procedure, which is the source for the information.
>>> |
>>> | So, my questions are:
>>> |
>>> | 1.
>>> | Since I have set all of the radiobutton controls to have the same
>>> GroupName
>>> | (either "TimeFrom" or "TimeTo") is it possible to find out the control
>>> name
>>> | of the radiobutton checked in each group - a function that you could

>>pass
>>> | the GroupName to which would return either the name of the checked
>>> | radiobutton control (great) or the value of the checked radiobutton
>>> control
>>> | (even better).
>>> |
>>> | Even if a function has to be written (I'm thinking something along the
>>> lines
>>> | of CheckedRadioButton(ByVal GroupName As String) As RadioButton) it's

>>got
>>> to
>>> | be better than the current state of affairs ) Any help you can offer

>>in
>>> | terms of writing such a function would be greatly appreciated - I

>>presume
>>> it
>>> | would have something to do with looping through each of the controls

in
>>> the
>>> | User Control or the page with the GroupName as given, and then

checking
>>to
>>> | see if ThatRadioButton.Checked is True...
>>> |
>>> | (PS - something like that should be added to the next point release,

or
>>> | definately ASP.NET v2.0)
>>> |
>>> | 2.
>>> | Failing that, is there a way of creating a radiobutton list, and then
>>> taking
>>> | the rows that are generated by said radiobutton list, and adding them

>to
>>a
>>> | table that already exists - either a System.Web.UI.WebControls.Table

or
>>a
>>> | System.Web.UI.HtmlControls.HtmlTable - and still be able to query the
>>> | RadioButtonList.SelectedValue value?
>>> |
>>> | 3.
>>> | Failing both of the above, what would you suggest? )
>>> |
>>> |
>>> | Cheers Lewis,
>>> | Anth
>>> |
>>> |
>>> |
>>> | "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
>>> | news:(E-Mail Removed)...
>>> | > Hi Anthony,
>>> | >
>>> | > I need more information to resolve the questions mentioned in the

>last
>>> | > paragraph of your post.
>>> | >
>>> | > What do you mean about putting the generated radiobutton list into a
>>> | table?
>>> | > Do you mean you want to put a radiobuttonlist control to a

TableCell,
>>or
>>> | do
>>> | > you mean you want to put each radio control in the radiobuttonlist

to
>>> each
>>> | > TableCell of a Table column?
>>> | >
>>> | > Thanks a lot.
>>> | >
>>> | > Lewis
>>> | >
>>> | > --------------------
>>> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
>>> | > | From: (E-Mail Removed) (Lewis Wang [MSFT])
>>> | > | Organization: Microsoft
>>> | > | Date: Tue, 09 Sep 2003 15:08:10 GMT
>>> | > | Subject: Re: Retrieving checked RadioButton controls which were

>>added
>>> to
>>> | > a Table control
>>> | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
>>> | > | MIME-Version: 1.0
>>> | > | Content-Type: text/plain
>>> | > | Content-Transfer-Encoding: 7bit
>>> | > |
>>> | > | Hi Anthony,
>>> | > |
>>> | > | It's possible to actually get the selected value by group name.

But
>>we
>>> | > need
>>> | > | to set the value attribution for every RadioButton. For example:
>>> | > |
>>> | > | RadioFrom.Attributes .Add("value",RadioFrom.Text);
>>> | > |
>>> | > | Then, we can get the selected value using Request.Form
>>> | > | ["TimeFrom"].ToString () in code behind.
>>> | > |
>>> | > | Hope this helps.
>>> | > |
>>> | > | Best regards,
>>> | > | Lewis
>>> | > | This posting is provided "AS IS" with no warranties, and confers

no
>>> | > rights.
>>> | > |
>>> | > | --------------------
>>> | > | | From: "Anthony Williams" <(E-Mail Removed)>
>>> | > | | References: <(E-Mail Removed)>
>>> | > | <(E-Mail Removed)>
>>> | > | | Subject: Re: Retrieving checked RadioButton controls which were
>>> added
>>> | > to
>>> | > | a Table control
>>> | > | | Date: Tue, 9 Sep 2003 09:23:01 +0100
>>> | > | | Lines: 184
>>> | > | | X-Priority: 3
>>> | > | | X-MSMail-Priority: Normal
>>> | > | | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>>> | > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>>> | > | | Message-ID: <(E-Mail Removed)>
>>> | > | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
>>> | > | | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com
>>> | > 81.137.71.124
>>> | > | | Path:

>>cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSF TNGP10.phx.gbl
>>> | > | | Xref: cpmsftngxa06.phx.gbl
>>> | > | microsoft.public.dotnet.framework.aspnet.webcontro ls:14497
>>> | > | | X-Tomcat-NG:

microsoft.public.dotnet.framework.aspnet.webcontro ls
>>> | > | |
>>> | > | | Lewis,
>>> | > | |
>>> | > | | Thanks for the reply - not only did you manage to answer one
>>> question,
>>> | > but
>>> | > | | you also tackled another which I was about to post to a

different
>>> | group
>>> | > -
>>> | > | | namely how do I manually populate a dataset - hehe. Thanks for

>the
>>> | > reply,
>>> | > | | but...
>>> | > | |
>>> | > | | Because I've already manually populated a table with radiobutton
>>> | > controls,
>>> | > | | I'm wondering whether or not it's possible to actually get the
>>> | selected
>>> | > | | value by group name - the reason I ask this specifically, is

>>because
>>> | > I've
>>> | > | | got a table with three columns - a radiobutton list won't allow

>me
>>> to
>>> | > keep
>>> | > | | my format in this way (will it?)
>>> | > | |
>>> | > | | Is there either a way to put the generated radiobutton list

into
>a
>>> | table
>>> | > | | that already exists, or - possibly - add each of the radiobutton
>>> | > controls
>>> | > | | not only to the table, but also to a radiobutton list?
>>> | > | |
>>> | > | | Cheers,
>>> | > | | Anthony
>>> | > | |
>>> | > | |
>>> | > | | "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in

>>message
>>> | > | | news:(E-Mail Removed)...
>>> | > | | > Hi Anthony,
>>> | > | | >
>>> | > | | > You can put the 240 ShortTimeStrings in a DataSet/DataTable

and
>>> bind
>>> | > it
>>> | > | to
>>> | > | | > a RadioButtonList. Then we can get the selected radio text by

"
>>> | > | | > RadioButtonList1.SelectedItem.ToString ()". Here is a code

>>snippet
>>> | for
>>> | > | | > demonstration, you may modify it to meet your requirements.
>>> | > | | >
>>> | > | | > protected DataSet GetSource()
>>> | > | | > {
>>> | > | | > . .
>>> | > | | > if(Session["ds"]!=null)return (DataSet)Session["ds"];
>>> | > | | > DataSet ds=new DataSet();
>>> | > | | > DataTable newtable=new DataTable ();
>>> | > | | > DataColumn cc1 = new
>>> | > | DataColumn("From",Type.GetType("System.String"),"" );
>>> | > | | > DataColumn cc2 = new DataColumn("To",
>>> | > Type.GetType("System.String"),"");
>>> | > | | > DataColumn cc3 = new DataColumn("Job",
>>> | > | Type.GetType("System.String"),"");
>>> | > | | > newtable.Columns.Add(cc1);
>>> | > | | > newtable.Columns.Add(cc2);
>>> | > | | > newtable.Columns.Add(cc3);
>>> | > | | > for(int i=0; i<240;i++)
>>> | > | | > {
>>> | > | | > DataRow dr=newtable.NewRow ();
>>> | > | | > dr["From"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
>>> | > | | > dr["To"]=CurTime.AddMinutes(i * 6).ToShortTimeString();
>>> | > | | > dr["Job"]="";
>>> | > | | > newtable.Rows .Add(dr);
>>> | > | | > }
>>> | > | | > ds.Tables .Add (newtable);
>>> | > | | > Session["ds"]=ds;
>>> | > | | >
>>> | > | | > return ds;
>>> | > | | > }
>>> | > | | >
>>> | > | | > private void Page_Load(object sender, System.EventArgs e)
>>> | > | | > {
>>> | > | | > if(!this.IsPostBack)
>>> | > | | > {
>>> | > | | > DataSet ds=GetSource();
>>> | > | | > RadioButtonList1.DataSource =ds;
>>> | > | | > RadioButtonList1.DataTextField ="From";
>>> | > | | > RadioButtonList1.DataBind ();
>>> | > | | > . . .
>>> | > | | > }
>>> | > | | > }
>>> | > | | >
>>> | > | | > private void Button1_Click(object sender, System.EventArgs e)
>>> | > | | > {
>>> | > | | > Response.Write ("From:" +

>RadioButtonList1.SelectedItem.ToString
>>> | ());
>>> | > | | > . . .
>>> | > | | > }
>>> | > | | >
>>> | > | | > Does this answer your question? Please let me know if you need
>>> more
>>> | > | | > information. Thanks.
>>> | > | | >
>>> | > | | > Best regards,
>>> | > | | > Lewis
>>> | > | | > This posting is provided "AS IS" with no warranties, and

>confers
>>> no
>>> | > | | rights.
>>> | > | | >
>>> | > | | > --------------------
>>> | > | | > | From: "Anthony Williams" <(E-Mail Removed)>
>>> | > | | > | Subject: Retrieving checked RadioButton controls which were
>>> added
>>> | > to a
>>> | > | | > Table control
>>> | > | | > | Date: Mon, 8 Sep 2003 12:28:26 +0100
>>> | > | | > | Lines: 73
>>> | > | | > | X-Priority: 3
>>> | > | | > | X-MSMail-Priority: Normal
>>> | > | | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>>> | > | | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>>> | > | | > | Message-ID: <(E-Mail Removed)>
>>> | > | | > | Newsgroups:

>>microsoft.public.dotnet.framework.aspnet.webcont rols
>>> | > | | > | NNTP-Posting-Host: host81-137-71-124.in-addr.btopenworld.com
>>> | > | | 81.137.71.124
>>> | > | | > | Path:
>>> | cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
>>> | > | | > | Xref: cpmsftngxa06.phx.gbl
>>> | > | | > microsoft.public.dotnet.framework.aspnet.webcontro ls:14469
>>> | > | | > | X-Tomcat-NG:
>>> microsoft.public.dotnet.framework.aspnet.webcontro ls
>>> | > | | > |
>>> | > | | > | Hi gang,
>>> | > | | > |
>>> | > | | > | I've created and populated a huge table, with 240 rows, with
>>> three
>>> | > | cells
>>> | > | | > per
>>> | > | | > | row. There are 240 RadioButton controls for "TimeFrom", and

>>240
>>> | > | | > RadioButton
>>> | > | | > | controls for "TimeTo".
>>> | > | | > |
>>> | > | | > | RadioButtons appearing in cell 1 have a GroupName of

>>"TimeFrom"
>>> | and
>>> | > | | those
>>> | > | | > | appearing in cell 2 have a GroupName of "TimeTo". The table
>>> | appears
>>> | > | | > | correctly (the code at the bottom of this post will generate

>>it
>>> | for
>>> | > | you
>>> | > | | if
>>> | > | | > | you create yourself a Table with ID "TSTable".
>>> | > | | > |
>>> | > | | > | My problem, for those of you falling asleep by now, is that

I
>>> | > haven't
>>> | > | | the
>>> | > | | > | faintest idea of how to retrieve the "TimeFrom" and "TimeTo"
>>> | > selected
>>> | > | | > | values. I can put a kludge together that will use
>>> | Request.Form(...)
>>> | > | but
>>> | > | | I
>>> | > | | > | was rather hoping that there'd be a .NET way.
>>> | > | | > |
>>> | > | | > | Any help would be greatly appreciated.
>>> | > | | > |
>>> | > | | > | Cheers,
>>> | > | | > | Tone
>>> | > | | > |
>>> | > | | > |
>>> | > | | > | ' ---------- Begin Create Table Code ----------
>>> | > | | > | Dim CurTime As New DateTime(Now.Year, Now.Month, Now.Day, 0,

>>0,
>>> 0)
>>> | > | | > |
>>> | > | | > | For i As Integer = 0 To 240 ' 24 hours in 240 six-minute

>(1/10
>>> hr)
>>> | > | | > | increments
>>> | > | | > |
>>> | > | | > | Dim Row As New TableRow
>>> | > | | > | Dim CellFrom As New TableCell
>>> | > | | > | Dim CellTo As New TableCell
>>> | > | | > | Dim CellJob As New TableCell
>>> | > | | > |
>>> | > | | > | CellFrom.Width = Unit.Pixel(60)
>>> | > | | > | CellTo.Width = Unit.Pixel(60)
>>> | > | | > |
>>> | > | | > | ' Create a radio button control which will select the

>From
>>> | > time...
>>> | > | | > | Dim RadioFrom As New RadioButton
>>> | > | | > | RadioFrom.GroupName = "TimeFrom"
>>> | > | | > | RadioFrom.EnableViewState = True
>>> | > | | > | RadioFrom.Text = CurTime.AddMinutes(i *

>>6).ToShortTimeString
>>> | > | | > |
>>> | > | | > | ' ...then add it to the "From" cell we just created
>>> | > | | > | CellFrom.Controls.Add(RadioFrom)
>>> | > | | > |
>>> | > | | > | ' And the same for selecting the To time...
>>> | > | | > | Dim RadioTo As New RadioButton
>>> | > | | > | RadioTo.GroupName = "TimeTo"
>>> | > | | > | RadioTo.EnableViewState = True
>>> | > | | > | RadioTo.Text = CurTime.AddMinutes(i *

>6).ToShortTimeString
>>> | > | | > |
>>> | > | | > | ' ...then add it to the "To" cell
>>> | > | | > | CellTo.Controls.Add(RadioTo)
>>> | > | | > |
>>> | > | | > | With Row.Cells
>>> | > | | > | .Add(CellFrom)
>>> | > | | > | .Add(CellTo)
>>> | > | | > | .Add(CellJob)
>>> | > | | > | End With
>>> | > | | > |
>>> | > | | > | RadioFrom.Dispose()
>>> | > | | > | RadioTo.Dispose()
>>> | > | | > |
>>> | > | | > | CellFrom.Dispose()
>>> | > | | > | CellTo.Dispose()
>>> | > | | > | CellJob.Dispose()
>>> | > | | > |
>>> | > | | > | Row.Dispose()
>>> | > | | > |
>>> | > | | > | Next
>>> | > | | > | ' ---------- End Create Table Code ----------
>>> | > | | > |
>>> | > | | > |
>>> | > | | > |
>>> | > | | >
>>> | > | |
>>> | > | |
>>> | > | |
>>> | > |
>>> | >
>>> |
>>> |
>>> |
>>>

>>
>>
>>

>
>


 
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
Radiobutton always has Checked = true, even when not selected Alan Silver ASP .Net 2 07-20-2006 12:08 PM
Problem with a custmo RadioButton and checked property. Esio Nunes ASP .Net Web Controls 0 10-18-2005 05:57 PM
Radiobutton Checked value is gone Mike ASP .Net Web Controls 2 07-22-2005 04:22 AM
RadioButton.Checked =?Utf-8?B?c29ubnk=?= ASP .Net 1 04-06-2005 10:47 PM
How to detect a "RadioButton" server control 's "Checked" property on the client side? bredal Jensen ASP .Net 0 04-26-2004 12:09 PM



Advertisments