当前位置:编程学习 > C#/ASP.NET >>

崩溃边缘:控件执行时出现Microsoft JScript 运行时错误: 'Page_Validators' 未定义?

[img=http://sz.photo.store.qq.com/http_imgload.cgi?/rurl2=577edb50221350d9c685c6a7b37e408fa32dfbb4497bc382d87f8ca4db68e6edd96adb2ce5dab9eb9d737546f66ec933614e1277962ef2773a8300577c706d9677a3cfe4228bb6f0d3a9520d5a9cdd07e02de1be][/img]

上图是我用DataGrid控件做的显示数据界面截图,当点击“同意”或者“不同意”时,就是显示“网页有错误:'Page_Validators' 未定义,请问是什么问题? 

ASP.NET代码如下 
<%if (flag){%>
<tr>
<td>
<asp:DataGrid id="hzListDataGrid" AllowPaging="True" PageSize="10" OnPageIndexChanged="Page_Change"
OnItemCommand="hzListDataGrid_ItemCommand" OnItemDataBound="hzListDataGrid_ItemDataBound"
width="100%" DataKeyField="bookingID" AutoGenerateColumns="False" CellPadding="2" CellSpacing="0"
BorderColor="#DDDDDD" BorderWidth="1" GridLines="Both" ShowHeader="true" HeaderStyle-BackColor="#F6F6F6"
HeaderStyle-Height="20" HeaderStyle-HorizontalAlign="center" ItemStyle-Height="20" ItemStyle-HorizontalAlign="left"
runat="server" Font-Size="9pt">
<ItemStyle HorizontalAlign="Left" Height="30px"></ItemStyle>
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" Height="30px" BackColor="#F6F6F6"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="applicant" ReadOnly="True" HeaderText="申请者">
<HeaderStyle HorizontalAlign="Center" Width="160px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="160px"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="grade" ReadOnly="True" HeaderText="专业年级">
<HeaderStyle HorizontalAlign="Center" Width="120px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="120px"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="实验名称">
<HeaderStyle HorizontalAlign="Center" Width="200px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="200px"></ItemStyle>
<ItemTemplate>
<asp:HyperLink ID="HyperLink" runat="server" NavigateUrl='<%# "../hzInfo.aspx?id="+DataBinder.Eval(Container.DataItem, "bookingID")%>' Target="_parent" Text='<%#DataBinder.Eval(Container.DataItem,"title")%>'>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="使用时间">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "time_Begin")%>
~
<%# DataBinder.Eval(Container.DataItem, "time_End")%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="state" ReadOnly="True" HeaderText="批复状态">
<HeaderStyle HorizontalAlign="Center" Width="80px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="80px"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="批复">
<HeaderStyle Width="100px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="100px"></ItemStyle>
<ItemTemplate>
<asp:LinkButton Text="同意" id="BtnApprove" CommandName="Approve" runat="server" />
<asp:LinkButton Text="不同意" id="BtnDisApprove" CommandName="DisApprove" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle NextPageText="上一页" Height="30px" Font-Size="10pt" Font-Names="Arial" Font-Italic="True"
PrevPageText="下一页" HorizontalAlign="Center" Mode="NumericPages"></PagerStyle>
</asp:DataGrid>
</td>
</tr>
<%}else{%>


后台CS代码如下: 
protected void hzListDataGrid_ItemCommand(Object sender, DataGridCommandEventArgs E)
        {
            if(E.Item.ItemType.ToString()!="Header"&&E.Item.ItemType.ToString()!="Pager")
            {
                int bookingID = Int32.Parse(hzListDataGrid.DataKeys[E.Item.ItemIndex].ToString());
                String command = ((LinkButton)E.CommandSource).CommandName;
                switch(command)
                {
                    case "Approve" :
                        ApproveBooking(bookingID);
                        break;
                    case "DisApprove":
                        DisApproveBooking(bookingID);
                        break;
                }
            }
        }
private void ApproveBooking(int bookingID)
        {
            syzxTest.db.database db=new syzxTest.db.database();
            db.ApproveBK(bookingID);
            db.Close();
            BindhzList();
        }

        private void DisApproveBooking(int bookingID)
        {
            syzxTest.db.database db=new syzxTest.db.database();
            db.DisApproveBK(bookingID);
            db.Close();
            BindhzList();
        }

补充:.NET技术 ,  组件/控件开发
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,