I have a gridview that includes dynamically created dropdownlist. When changing the dropdown values and doing a mass update on the grid (btnUpdate.click), I have to create the controls in the page init so they will be available to the viewstate. However, I have several other buttons that also cause a postback and I don't want to create the controls in the page init, but rather later in the button click events.
How can I tell which control fired the postback while in page_init? __EVENTTARGET = "" and request.params("btnUpdate") is nothing
Best Answer
It is possible to determine which control caused a PostBack by looking at
Request.Form["__EVENTTARGET"]
. The problem with this is that button ids will not show unless you set their UseSubmitBehavior to false. Here's an example:.aspx.cs
.aspx