帮助!
我有一个带有<asp:TemplateField><ItemTemplate>
组合的GridView。在这个组合里面,我有一个<asp:ImageButton ...>
它看起来不错,但每次点击这个按钮我都会收到一个错误:
Microsoft JScript运行时错误: Sys.WebForms.PageRequestManagerServerErrorException:未知错误 在服务器上处理请求时发生。状态代码 从服务器返回的是:500
我甚至没有看到按钮触发的事件。
这是我的HTML代码:
<asp:GridView
ID="PuckGridView"
runat="server"
EmptyDataText="Sorry, no data available"
AutoGenerateColumns="False"
AllowSorting="True"
Font-Size = "X-Small"
Width = "1150px"
Height = "410px"
onselectedindexchanged="PuckGridView_SelectedIndexChanged"
onrowcommand="RowUserActivity"
onpageindexchanging="PuckGridView_PageIndexChanging"
onrowdatabound="PuckGridView_RowDataBound"
GridLines="Horizontal"
onsorting="PuckGridView_Sorting"
HeaderStyle-HorizontalAlign="Left">
<AlternatingRowStyle BackColor="#99CCFF" ForeColor="Black" />
<Columns>
<asp:TemplateField SortExpression="Status" HeaderText="Status">
<ItemTemplate>
<asp:ImageButton runat="server" ImageUrl='<%# "~/Images/" + Eval("StatusImage").ToString() %>' CommandName="UpdateStatus" />
<%-- <asp:Image ID="statusImage" runat="server" ImageUrl='<%# "~/Images/" + Eval("StatusImage").ToString() %>' />--%>
<asp:Label ID="status" runat="server" Text='<%# Bind("StatusText") %>'></asp:Label>
<br />
<asp:Image ID="onCallImage" runat="server" ImageUrl='<%# "~/Images/" + DisplayCorrectOnCallImage(Eval("OnCallImage")) %>' />
<asp:HiddenField ID="HiddenEmail" runat="server" Value='<%# Eval("Email") %>' />
<asp:HiddenField ID="HiddenUserName" runat="server" Value='<%# Eval("UserName") %>' />
<asp:HiddenField ID="HiddenFirstName" runat="server" Value='<%# Eval("FirstName") %>' />
<asp:HiddenField ID="HiddenLastName" runat="server" Value='<%# Eval("LastName") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" SortExpression="FirstName" DataField="FirstName" HeaderText="FirstName" Visible="true" />
<asp:BoundField ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" SortExpression="LastName" DataField="LastName" HeaderText="LastName" Visible="true" />
<asp:BoundField ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" DataField="OfficePhone" HeaderText="Phone" Visible="true" />
<asp:BoundField ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" SortExpression="TeamRole" DataField="TeamRole" HeaderText="Team/Role" Visible="true" />
<asp:BoundField ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" SortExpression="Location" DataField="Location" HeaderText="Location" Visible="true" />
<asp:ButtonField HeaderText="Mail" ButtonType="Image" CommandName="SendMail" ImageUrl="~/Images/mail.gif" Visible="true"/>
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID="imgHours" ToolTip=' <%# Eval("Hours") %> ' ImageUrl='<%# "~/Images/clock.gif" %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField ItemStyle-HorizontalAlign="Left" DataField="Message" HeaderText="Message" Visible="true" />
</Columns>
<HeaderStyle BackColor="#CCCCCC" />
</asp:GridView>
答案 0 :(得分:1)
尝试查看是否存在任何无效的html标记。或尝试viewstate = false
答案 1 :(得分:0)
尝试删除此行:
<%-- <asp:Image ID="statusImage" runat="server" ImageUrl='<%# "~/Images/" + Eval("StatusImage").ToString() %>' />--%>
我之前在模板中评论了一些事情
同时检查您的
onselectedindexchanged="PuckGridView_SelectedIndexChanged"
事件,因为当您点击行
时,这也可能会触发