Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Which button clicked?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires Web
Divers
Thread ID:
00858694
Message ID:
00859099
Vues:
9
That did it.

As I wrote the test code I wondered which event would fire first, the ItemCommand or the SelectedIndexChanged event. Interestingly, the ItemCommand event fired but the SelectedIndexChanged event did not.

Thanks


>>How do you determine which button was clicked when you have multiple Select type bound columns?
>
>
>You need to implement the ItemCommand event of the DataGrid and then do something like this:
>
>
>protected void ItemCommand(object sender, DataGridCommandEventArgs e)
>{
>	// *** Button command Names contain Sku value if set
>	if (e.CommandName != null && e.CommandName != "" && e.CommandName != "Page")
>	{
>		// *** If we clicked on one of the items to buy - redirect to the item page
>		string sku = e.CommandName;
>		string qty = ((TextBox) e.Item.FindControl("qty")).Text;
>		if (sku != null && sku!="")
>		{
>			Server.Transfer("Item.aspx?sku=" + sku.Trim() + "&qty=" + qty + "&Action=Add");
>			//Response.Redirect("Item.aspx?sku=" + sku.Trim() + "&qty=" + qty + "&Action=Add");
>		}
>		
>	}
>}
>
>
>Note that this event fires for any clicks you make on buttons, page links etc. so it's important that you filter out all the stuff you're not interested in. In the above example I filter out Page requests and nulls before picking up the values.
>
>Notice also that you get a reference to the selected row with the e.Item property. From there you can query individual values of that row by using FindControl and then retrieving the values.
>
>It's very flexible...
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform