Prev: ConfigurationErrorsException, Event Code 3008, system.web/identity
Next: Freeze columns in GridView ASP.NET2.0(Urgent)
From: Mike P on 25 Apr 2006 15:19 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 : protected 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 http://www.developersdex.com ***
From: Neutrino on 25 Apr 2006 15:43 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 26 Apr 2006 04:14 Hi, This doesn't work - I get the error 'Rows is a property but is used like a method'. Mike *** Sent via Developersdex http://www.developersdex.com ***
From: yossimotro on 26 Apr 2006 06:11 I think you shuold use [] instead of (). anyway, where do you call this function from? I mean, what calls it? Yossi.
From: Mike P on 26 Apr 2006 06:48
This is in the RowCommand event. *** Sent via Developersdex http://www.developersdex.com *** |