本文介绍了如何避免从页面加载调用OnItemCommand方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我在asp.net页面中创建了DataList。 Datalist有一个OnItemCommand(即OnItemCommand =EquipmentsListDatalist_ItemCommand)。当我刷新页面时,调用EquipmentsListDatalist_ItemCommand方法。是否有任何选项可以停止从页面加载中调用EquipmentsListDatalist_ItemCommand方法。 这是我的编码: asp: < asp:DataList ID =SampleDataListrunat =serveronItemCommand = EquipmentsListDatalist_ItemCommandDataKeyField =productModel> /// /// /// < / asp:DataList> c#: public void EquipmentsListDatalist_ItemCommand( Object sender,Eventargs e) { /// /// /// } 我在Page_Load方法中没有任何关于此方法的含义。但是,只要页面加载发生,这个方法就会被调用。任何人都可以请更新我为什么会这样,以及如何避免这种情况。 对不起,如果我的沟通不畅。 提前感谢您的帮助:)解决方案 I have created DataList in my asp.net page. The Datalist has an OnItemCommand (i.e OnItemCommand="EquipmentsListDatalist_ItemCommand"). When ever i refresh my page, the method EquipmentsListDatalist_ItemCommand is getting invoked. is there any option to stop calling EquipmentsListDatalist_ItemCommand method from page load.Here is my coding : asp : <asp:DataList ID="SampleDataList" runat="server" onItemCommand="EquipmentsListDatalist_ItemCommand" DataKeyField="productModel">///////// </ asp:DataList>c# :public void EquipmentsListDatalist_ItemCommand(Object sender , Eventargs e){/////////}I have not meant anything regarding this method in Page_Load method. But still this method is getting called whenever the Page Load happens. Can anyone please update me why this happens and how to avoid this.Sorry,if my communication is poor.Thanks in advance for your help :) 解决方案 这篇关于如何避免从页面加载调用OnItemCommand方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-23 12:50