我有正常触发并执行逻辑的Gridview RowCommand。 当我部署到服务器时,页面刷新并且网格消失。 请注意,我的本地环境使用相同的数据库,相同的用户,并且使用相同的代码。 Web.config也很正常。 知道为什么它可以在一种环境下而不在另一种环境下工作吗?
我检查了viewstate是否为false。 它是相同的数据库和代码,并且是登录用户。 数据绑定发生在我单击搜索按钮时,无法将其放入!postback
<asp:GridView ID="gvUsersList" runat="server"
OnRowCommand="gvUsersList_RowCommand" AutoGenerateColumns="false"
AllowPaging="True" AllowCustomPaging="true" PageSize="10" OnPageIndexChanging="gvUsersList_PageIndexChanging">
<Columns>
<asp:BoundField HeaderText="Request_ID" AccessibleHeaderText="Request_ID" DataField="Request_ID"
HeaderStyle-HorizontalAlign="Left" Visible="false"></asp:BoundField>
<asp:BoundField HtmlEncode="false" AccessibleHeaderText="<%$ Resources:Resource_5_0_Admin,PersonalisedCardRequests_Details_ChildFirstName %>"
DataField="ChildFirstName" HeaderText="<%$ Resources:Resource_5_0_Admin,PersonalisedCardRequests_Details_ChildFirstName %>">
<ControlStyle Width="100px" />
<ItemStyle Wrap="true" Width="100px" />
</asp:BoundField>
<asp:BoundField HtmlEncode="false" AccessibleHeaderText="<%$ Resources:Resource_5_0_Admin,PersonalisedCardRequests_Details_ChildLastName %>"
DataField="ChildLastName" HeaderText="<%$ Resources:Resource_5_0_Admin,PersonalisedCardRequests_Details_ChildLastName %>">
<ItemStyle Wrap="true" Width="100" />
</asp:BoundField>
<asp:BoundField HtmlEncode="false" AccessibleHeaderText="<%$ Resources:Resource_5_0_Admin,PersonalisedCardRequests_Details_DOB %>"
DataField="ChildDateOfBirth" DataFormatString="{0:dd/MM/yyyy}" HeaderText="<%$ Resources:Resource_5_0_Admin,PersonalisedCardRequests_Details_DOB %>">
<ControlStyle Width="50px" />
<ItemStyle Wrap="true" Width="50px" />
</asp:BoundField>
<asp:BoundField HtmlEncode="false" AccessibleHeaderText="<%$ Resources:Resource_5_0_Admin,PersonalisedCardRequests_Details_RequestDate %>"
DataField="RequestDate" DataFormatString="{0:dd/MM/yyyy}" HeaderText="<%$ Resources:Resource_5_0_Admin,PersonalisedCardRequests_Details_RequestDate %>">
<ItemStyle Wrap="true" Width="100" />
</asp:BoundField>
<asp:BoundField HtmlEncode="false" AccessibleHeaderText="<%$ Resources:Resource_5_0_Admin,PersonalisedCardRequests_Details_ReferenceNumber %>"
DataField="ReferenceNumber" HeaderText="<%$ Resources:Resource_5_0_Admin,PersonalisedCardRequests_Details_ReferenceNumber %>">
<ItemStyle Wrap="true" Width="100" />
</asp:BoundField>
<asp:TemplateField ShowHeader="true" HeaderText="<%$ Resources:Resource_5_0_Admin,ViewDetails %>">
<ItemTemplate>
<asp:LinkButton ID="detailsBtn" runat="server" CausesValidation="False" CommandName="Select"
Text="<%$ Resources:Resource_5_0_Admin,ViewDetails %>" CommandArgument='<%#Eval("Request_ID")%>'></asp:LinkButton>
</ItemTemplate>
<ControlStyle Width="70px" />
<ItemStyle Width="70px" Wrap="True" />
</asp:TemplateField>
</Columns>
</asp:GridView>
后面的代码是
protected void gvUsersList_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
if (e.CommandName == "Select")
{
string lSelectedRequest_Id = e.CommandArgument.ToString();
WriteLogEntry("Select ", "Selected Request ID:" + lSelectedRequest_Id);
string lUpdateURL = QueryStringManager.GetEncryptedPageURL("~/SiteSettings/CardRequests/ChildRequestDetails.aspx", new string[] { QueryStringManager.enumQueryStringKeys.ID + "=" + lSelectedRequest_Id });
Response.Redirect(lUpdateURL);
}
}
catch (Exception ex)
{
if (!ExceptionHandler.IsUserFriendly(ex))
{
ex.Data.Add("PageName", "ChildPersonalisedCardRequests");
ex.Data.Add("EventName", "accGrdCountrieslist_RowCommand");
ExceptionHandler.handle(ex);
}
else
{
throw ex;
}
}
}