A.aspx中包含Datagrid.ascx控件,Datagrid.ascx控件中只有一个显示数据的Datagrid,
为什么Datagrid_SortCommand事件不执行,点击Datagrid的列头,Datagrid.ascx的Page_Load、InitializeComponent事件都被执行了,但是Datagrid_SortCommand事件不执行Datagrid设置,列头自动加载
<asp:datagrid
id="Datagrid" runat="server" BorderWidth="1px" BorderStyle="None" Width="100%" EnableViewState="False" AllowSorting="True" AllowCustomPaging="True" PageSize="15"> <PagerStyle Mode="NumericPages"></PagerStyle>
</asp:datagrid>
为什么Datagrid_SortCommand事件不执行,点击Datagrid的列头,Datagrid.ascx的Page_Load、InitializeComponent事件都被执行了,但是Datagrid_SortCommand事件不执行Datagrid设置,列头自动加载
<asp:datagrid
id="Datagrid" runat="server" BorderWidth="1px" BorderStyle="None" Width="100%" EnableViewState="False" AllowSorting="True" AllowCustomPaging="True" PageSize="15"> <PagerStyle Mode="NumericPages"></PagerStyle>
</asp:datagrid>
解决方案 »
- 用c#操作sql数据库语句
- dnn user login register 界面 如何汉化
- 有没有详细介绍ajaxpro的文章啊
- 关于字符串过滤问题?
- 在.NET中DATAGRID的问题
- 开发中正常的网页上传后出现 500-内部服务器错误 无法访问
- 照片自动播放程序怎样跳过非照片?
- ***求教(JavaScript):有没有打开一个无菜单、无工具栏、无地址栏窗口的新方法***
- 在Table控件中如何实现分页
- asp.net 4.0 + access + SampleAccessProviders 在虚拟服务器上运行问题!
- 层被框架挡住的问题!急着送分,谁接啊~~~
- 调查一下,大家做项目是前台和后台的分工
this.Datagrid.SortCommand += new System.EventHandler(this.Datagrid_SortCommand);
但我在PageLoad中有这句:
if (!this.IsPostBack)
bindGrid();
看起来很正常吧?但这么写总触发不了dataTab_SortCommand()事件.
如果去掉 if (!this.IsPostBack) 这句,就可以正常触发事件.问题好奇怪.难道不datagrid.DataBind()就不能触发事件么??
今天能解决的另开一帖领分.
在InitializeComponent()函数中有这句话:
this.Datagrid.SortCommand += new System.EventHandler(this.Datagrid_SortCommand);
你的EnableViewState="False" 了.
设为EnableViewState="True" 就没问题了.
在PageLoad中:
if (!this.IsPostBack)
{
...
this.Datagrid.DataBind();
}
的话.