Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Best Way to Find Check Boxes on a DataList

Reply
Thread Tools

Best Way to Find Check Boxes on a DataList

 
 
Fao, Sean
Guest
Posts: n/a
 
      01-25-2006
I've been using the following technique to locate CheckBoxes on a DataList:

private void Button1_Click(object sender, System.EventArgs e)
{
CheckBox checkbox;

foreach (DataGridItem dgitem in this.AuthorsDataGrid.Items)
{
if ((checkbox = (CheckBox) dgitem.FindControl("DataGridCheckBox"))
!= null)
System.Diagnostics.Debug.WriteLine("found it...");
else
System.Diagnostics.Debug.WriteLine(dgitem.ID);
}
}

The only real flaw (that I know of) using this technique is that it
breaks if anybody changes the ID of the CheckBox controls on the DataList.

Is this an acceptable technique? Is there a better way?

Thank you in advance,

--
Sean
 
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
how to check all check boxes in repeater control kris ASP .Net 1 09-22-2005 07:16 PM
how to check all check boxes in repeater control kris ASP .Net 0 09-22-2005 06:29 PM
how to check all check boxes in repeater control kris ASP .Net 0 09-22-2005 06:29 PM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
select all check boxes at a time with check all [Javascript] [Chatakondu Gallery] Suresh Javascript 2 04-22-2004 03:47 PM



Advertisments