Attached is a very small web site that does what you want (zipped). The
steps are:
1. Create the web site
2. Drag the customers table from Northwind onto the page to create a data
source control and a grid
3. use the smart tag in the grid to add a new (command field) column. I
added a button field and set its command name to Select, its button type to
Link its header to My Button Field and its text (creatively) to My Button.
4. Click on the grid and set its RowCommand Event as follows:
protected void GridView1_RowCommand( object sender, GridViewCommandEventArgs
e )
{
int index = Convert.ToInt32( e.CommandArgument );
myFunction( index );
}
This grabs the index of the row from the CommandArgument property of the
GridViewCommandEventArgs passed into the event. You can then use it in your
server side method, thus...
private void myFunction (int rowIndex)
{
Response.Write ("Do some action with row " + rowIndex.ToString());
}
Remember, however that the rows are zero-based (the first row is row zero.
Best of luck.
--
Jesse Liberty
Author, Programmer
Microsoft MVP
"graphicsxp" <sa*************@googlemail.comwrote in message
news:11*********************@m79g2000cwm.googlegro ups.com...
Hi,
I've added a linkbutton field to my gridview. Now I would like that
when the user clicks on it for a particular row, a server-side function
should be executed, which takes as parameters the id of the selected
row. How can I do that ?
Thanks