I have a gridview with a linkbutton inside a <HeaderTemplate>
. There is an event handler for a click on this button. Now if I bind data to the gridview on every Page_Load
event, then this event fires. But if I bind data to the gridview inside if (Page.IsPostBack == false)
, then this event doesn't fire.
Is it that after the pageload it realizes there is no data in the gridview hence ignore events generated from the grid?
How do I slove the problem ?
The LinkButton
behaves like a Button
The LinkButton control has the same appearance as a HyperLink control, but has the same functionality as a Button control.
That means it triggers a postback when clicked. So the only way to get the click event to fire, is to wire up the handler if Page.Postback=true
. (Keep in mind that since HTTP is stateless, if you wire up an event handler on the initial page load, it won't "remember" upon postback.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.