Click here to Skip to main content
16,012,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all..

How can i find data gridview row index in row commend event?by using for loop..i need each row index by using textboxes.. please give sample code..
Posted
Comments
_Amy 25-Jul-12 1:50am    
Your question is not clear.

1 solution

You must be aware of this, that RowCommand event is raised when a button is clicked in the GridView control. Which enables you to provide an event-handling method that performs a custom routine whenever this event occurs.
Refer more detailed description here:
GridView.RowCommand Event[^]

This is how you can get the index of GridView row using RowCommand:
C#
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Show")
          {
            int index = Convert.ToInt32(e.CommandArgument);
            int documentID = Convert.ToInt32(GridView1.DataKeys[index].Value);

             // Write your further code
          }
    }

Ref.:Get RowIndex In GridView RowCommand Event Using DataKey[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900