From: Mike P on
I have a ButtonField in my GridView with a CommandName, and I have a
method which I am using to capture each click of the button :


void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)

if (e.CommandName == "OpportunityDetails")




My question is, how do I get hold of any of the values within the row
that I have clicked? I want to get at the ID field of the row that I
have clicked because I need to redirect to another page which will be a
DetailsView for this particular record.

Any help would be really appreciated.

*** Sent via Developersdex ***
From: Neutrino on
The index of the row from were the command originated is in the
CommandArgument of the GridViewCommandEventArgs parameter of the event.

To get the GridViewRow do something like this (in C#):

GridViewRow row = GridView1.Rows(Convert.ToInt32(e.CommandArgument));

You may then use FindControl to get the controls within the row.

Hope this helps!

From: Mike P on

This doesn't work - I get the error 'Rows is a property but is used like
a method'.


*** Sent via Developersdex ***
From: yossimotro on
I think you shuold use [] instead of ().
anyway, where do you call this function from? I mean, what calls it?


From: Mike P on
This is in the RowCommand event.

*** Sent via Developersdex ***