Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Which button clicked?
Message
General information
Forum:
ASP.NET
Category:
Web forms
Miscellaneous
Thread ID:
00858694
Message ID:
00859099
Views:
10
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...
Previous
Reply
Map
View

Click here to load this message in the networking platform