Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine which button was clicked
Message
De
06/03/2007 08:58:36
Alexandre Palma
Harms Software, Inc.
Alverca, Portugal
 
 
À
06/03/2007 08:21:24
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
ASP.NET
Divers
Thread ID:
01200831
Message ID:
01200997
Vues:
27
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform