Results 1 to 5 of 5

Thread: [RESOLVED] GridView - How to refer to the row that is updating

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2010
    Posts
    8

    Resolved [RESOLVED] GridView - How to refer to the row that is updating

    Hi,

    I'm facing the following issue:
    I have a gridview that allows updating. I only want to show the relevant fields to the user. As a result I hide the ID field of the records. But I need this value as a parameter for my update command.
    Apparently the value is always passed as 0 when the field is set invisible. When the field is set visible, the right value is passed.
    I know it is possible to refer to a selected row and its controls, to get their values, even for invisible fields. This is what I want to do when the row is updating, in order to get the ID value of the label control which holds the ID value.
    How do I refer to the row that is updating? I experienced that the row is not considered 'selected', so the SelectedRow property of the gridview does not do the trick.

    Tnx

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: GridView - How to refer to the row that is updating

    Hey,

    Can you show the code that you are using? Both the markup and the server side code?

    Have you set the DataKeyNames property of the GridView?

    Gary

  3. #3
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Re: GridView - How to refer to the row that is updating

    Try this one...

    it also contains the code 4 downloading...

    hope that helps...@

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2010
    Posts
    8

    Re: GridView - How to refer to the row that is updating

    Quote Originally Posted by dnanetwork View Post
    Great... exactly what I was looking for...
    C# Code:
    1. Label s_lblID = (Label)GridView1.Rows[e.RowIndex].FindControl("lblID");
    Now I can get the value from s_lblID.text
    It was e.RowIndex I needed... so simple...

    Tnx
    Last edited by mikedp; Mar 13th, 2010 at 10:05 AM.

  5. #5
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Re: [RESOLVED] GridView - How to refer to the row that is updating

    you are welcome....

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