Results 1 to 4 of 4

Thread: looping thru a datagrid

  1. #1

    Thread Starter
    Addicted Member KingSatan's Avatar
    Join Date
    Feb 2006
    Posts
    185

    looping thru a datagrid

    i was wondering if there IS a way to loop thru a datagrid?
    im trying to loop thru a datagrid to see which checkboxes were checked and which werent
    and if the checkbox is checked its added to this second datagrid that is on the page
    Last edited by KingSatan; Apr 9th, 2007 at 05:21 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: looping thru a datagrid

    Can you please specify that this is a Web app when it's a Web app so people know?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member KingSatan's Avatar
    Join Date
    Feb 2006
    Posts
    185

    Re: looping thru a datagrid

    yeah sorry its a web app and im using VS 2003 c#

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: looping thru a datagrid

    Loop through the datagrid's items collection.

    Code:
    foreach( DataGridItem dgi in dg.Items )
        {
            HtmlInputCheckBox chkBox = (HtmlInputCheckBox)dgi.FindControl("YourCheckBoxId") ;
            if( chkBox !=null && chkBox.Checked )
            {
                //Ta daaaa!
            }
        }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width