简体   繁体   中英

OnItemCommand Event of the DataGrid is not firing

I am having a DataGrid in one usercontrol which is getting 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().

http://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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM