How to retrieve a column from a selected GridView row.

Discussion in 'ASP .Net' started by Steve Kershaw, Apr 20, 2007.

  1. Hi,

    I have a GridView in which I have selected a row. I now want to use
    the 1st column value of that selected row in another GridView as an
    input to select the particular row in the second GridView. I know that
    "GridView1.SelectedRow.Cells[0]" dosen't work along with some other
    things I have tried.

    Can anybody help me with this?!

    Thanks in advance.
    Steve
     
    Steve Kershaw, Apr 20, 2007
    #1
    1. Advertising

  2. Steve Kershaw

    Randy Smith Guest

    Hi,
    I've got this code, and seems to work quite well:

    foreach (GridViewRow row in GridView1.Rows)
    {
    CheckBox chk1 = (CheckBox) row.FindControl("chk1");
    if (chk1.Checked == true)
    {
    //code goes here
    }
    }

    The point of this code is that it is necessary to "find" the control, and
    place the contents into a newly created variable. In the case above, the
    variable is "chk1", but it can be anything. Although it might be confusing,
    the name of the control on the aspx form is also "chk1".

    HTH, Randy




    "Steve Kershaw" <> wrote in message
    news:...
    > Hi,
    >
    > I have a GridView in which I have selected a row. I now want to use
    > the 1st column value of that selected row in another GridView as an
    > input to select the particular row in the second GridView. I know that
    > "GridView1.SelectedRow.Cells[0]" dosen't work along with some other
    > things I have tried.
    >
    > Can anybody help me with this?!
    >
    > Thanks in advance.
    > Steve
    >
     
    Randy Smith, Apr 28, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ABC
    Replies:
    1
    Views:
    955
    Patirck Ige
    Oct 7, 2005
  2. H5N1
    Replies:
    0
    Views:
    2,723
  3. johnsonlim026
    Replies:
    0
    Views:
    938
    johnsonlim026
    Feb 27, 2010
  4. Want to add row under selected row of gridview

    , Feb 16, 2007, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    304
  5. Selected Row Only GridView Row Visible?

    , Oct 17, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    296
Loading...

Share This Page