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
LinkButtonbehaves like aButtonThat 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.)