How to programatically set GridView selected row?

Discussion in 'ASP .Net Web Controls' started by 11D.Universe, Jun 17, 2007.

  1. 11D.Universe

    11D.Universe Guest

    I've got a GridView control (GridView1) containing several fields
    (Field1, Field2, ...) from a SQL table

    If I set the selected row using: GridView1.SelectedIndex=1

    Then how do I get the value of one of the fields in that row - say
    Field2?
     
    11D.Universe, Jun 17, 2007
    #1
    1. Advertising

  2. you can use

    ((TextBox)GridView1.SelectedRow.FindControl("controlname")).text
    assuming the field is type of textbox.You can typecast it wahtever the type
    of the control.
    Hope this helps

    "11D.Universe" wrote:

    > I've got a GridView control (GridView1) containing several fields
    > (Field1, Field2, ...) from a SQL table
    >
    > If I set the selected row using: GridView1.SelectedIndex=1
    >
    > Then how do I get the value of one of the fields in that row - say
    > Field2?
    >
    >
     
    Sriram Surapureddy, Jun 20, 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. H5N1
    Replies:
    0
    Views:
    2,723
  2. =?Utf-8?B?R2VyaGFyZA==?=

    gridview row programatically set to edit mode

    =?Utf-8?B?R2VyaGFyZA==?=, Sep 29, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    14,885
    =?Utf-8?B?R2VyaGFyZA==?=
    Sep 29, 2006
  3. Replies:
    5
    Views:
    667
  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