问题描述
我在单个"aspx"页面中设计和访问了大约10个用户控件.
每个用户控件都具有!IsPostback"条件的页面加载事件,在该事件中我将详细信息绑定到Grid View.
我基于相应的菜单/按钮单击访问控件,以将该控件加载到aspx页面上.但是在单击菜单或按钮时,"IsPostback"为"true",并且在加载控件时,用户控件中可用的网格视图未绑定.
那么如何在加载用户控件时将IsPostBack设置为false?还是有其他解决方案来解决此问题?
请回复.紧急.
问候,
Rashmi.MK
Hi,
I have around 10 User Controls designed and accessed in Single "aspx" page.
Each User Control has Page Load event with "!IsPostback" condition where I am binding details to Grid View.
I access controls based on respective menu/button click to load that control on aspx page. But on Click of menu or button "IsPostback" is "true" and Grid view available in User Control is not binding when control is loaded.
So how can I make IsPostBack as false while loading User Control? Or is there any other solution to solve this problem?
Please reply. Its Urgent.
Regards,
Rashmi.MK
推荐答案
void loadgrid()
{
ds=new dataset()
ad=new sqldataadapter("select * from table",con);
ad.fill(ds);
gridview1.datasource=ds;
gridview1.databind();
}
在页面加载中调用loadgrid函数.
call the loadgrid function in page load.
void button_click(sender sender,enentargs e)
{
--your code here
-- now call your method here
}
这篇关于Web用户控制问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!