Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determine which button was clicked
Message
From
06/03/2007 08:58:36
Alexandre Palma
Harms Software, Inc.
Alverca, Portugal
 
 
To
06/03/2007 08:21:24
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, United States
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
Miscellaneous
Thread ID:
01200831
Message ID:
01200997
Views:
25
Jerry why don't you add the PK field into the grid and put the visible property of the column to false, that's what I always do.

>William,
>
>Yes, the RowCommand (e.CommandName) will tell me which button was clicked, but it won't pass the table's primary key value like it does with the SelectedIndexChanged event and (this.GridView1.SelectedValue).
>
>I know that with RowCommand I can get a value in the grid with:
>
>int index = Convert.ToInt32(e.CommandArgument);
>GridViewRow row = this.GridView1.Rows[index];
>
>But I need to get the primary key field which is not displayed in the grid.
>
>My grid actually has a four buttons which perform four different functions. All the functions need the primary field value. I like the SelectedIndexChanged event because of the SelectedValue property, but that would mean all four buttons need the "CommandName" property set to "SELECT". This gives me the primary key value in SelectedValue but then I can't tell which button the user pressed.
>
>Perhaps there is a better way of doing this?
>
>Thanks,
>
>Jerry
>
>
>
>
>>>I have a webform with a gridview that has 4 columns. Two of the columns are "ButtonField". One button is for Edit, one is button is for Delete. Both buttons's "CommandName" contains "SELECT". The SelectedIndexChanged of the grid points to "MyMethod()".
>>>
>>>When I run the form and click on either button, "MyMethod()" gets control, but how can I tell which button was pressed, the Edit or the Delete?
>>>
>>>Or is there a better way to do this?
>>>
>>>Thanks,
>>>
>>>Jerry
>>
>>Check out the RowCommand method of a grid.
Alexandre Palma
Senior Application Architect
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform