OnItemCommand Event of the DataGrid is not firing
I am having a DataGrid in one usercontrol which is g开发者_Go百科etting filled with some data when I press some button(ouside it). This Datagrid is filled by one linkbutton also. When I click this LinkButton then OnItemCommand or SelectedIndexChanged should fire, but both the events are not firng. While the control's PageLoad event is firing.
Please let me know where I am doing the mistake.
Thanks
Is your control added dynamically, using something like Page.LoadControl()? If so, events won't fire unless the control is dynamically added for each request. That's the only way the control tree can be properly built again. I usually do this in Init().
https://web.archive.org/web/20211029043701/https://www.4guysfromrolla.com/articles/042402-1.aspx
For those that see this post, looking for an answer. Most likely, you're rebinding the data to the datagrid on every call. Use a conditional and check !this.IsPostBack.
精彩评论