2014-04-13 30 views
2

好吧!所以自從過去一個星期以來,我試圖找到爲什麼我得到這個錯誤,但沒有任何成功。試圖瞭解gridview中的分頁錯誤的來源

我的網格視圖設置正好在我的網站中間,我只是試圖從數據庫中繪製大量的行(比如結果表格中的20+行)。當我設置AllowPaging =「true」並設置PageSize =「10」我得到 HTTP錯誤404.15-未找到請求過濾模塊配置爲拒絕查詢字符串過長的請求。在點擊數網格視圖2或第3頁當網站加載

但是,當我刪除AllowPaging =「真」每頁=「10」我得到長足的條目錯誤。

CODE

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="StaffDetailsForStaffSalaryMonitoringSystemAdd.aspx.cs" Inherits="StaffDetailsForStaffSalaryMonitoringSystemAdd" %> 

<!DOCTYPE html> 

    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head runat="server"> 
    <title></title> 
     <style type="text/css"> 

     * 
     { 
      margin:0px; 
      padding:0px; 
     } 

     body 
     { 
      font-family:Segoe UI; 
     } 


     div#KohinoorBanner 
     { 
      background-color:#004883; 
      display:block; 
      height:100px; 
      position:relative; 
     } 
     div#KohinoorBanner img 
     { 
      position:absolute; 
      left:15px; 
      bottom:15px; 
     } 





     /* -------Styling the Horizontal Navigation Menu---------- */ 
     div#KohinoorNavigationMenu 
     { 
      /*outline:solid red 1px;*/ 
      height:30px; 
      position:relative; 
      top:1px; 
      background-color:#980000; 
      z-index:1; 
     } 

     ul#HorizontalNavigationMenu,ul#PayRollSubMenu,ul#MastersSubMenu,ul#EnquirySubMenu,ul#StudentDetailsSubMenu,ul#Account,ul#TellecallingSubMenu,ul#ReportsSubMenu,ul#LiveConversationSubMenu 
     { 
      list-style-type:none; 
     } 
     ul#HorizontalNavigationMenu a 
     { 
      text-decoration:none; 
      display:block; 
      width:175px; 
      height:30px; 
      background-color:#980000; 
      color:white; 
      line-height:30px; 
      font-family:Sans-Serif; 
      font-size:13px; 
      outline:solid white 1px; 
     } 
     ul#HorizontalNavigationMenu li 
     { 
      position:relative; 
      float:left; 
      width:175px; 
      display:block; 
     } 
     ul#HorizontalNavigationMenu ul#PayRollSubMenu 
     { 
      /*outline:solid blue 2px;*/ 
      position:relative; 
      display:none; 
      width:175px; 
      top:1px; 
     } 
     ul#HorizontalNavigationMenu>li:hover ul#PayRollSubMenu 
     { 
      display:block; 
     } 

     ul#HorizontalNavigationMenu ul#PayRollSubMenu a 
     { 
      display:block; 
      width:175px; 
      background-color:#f89800; 
     } 
     ul#HorizontalNavigationMenu li:hover>a 
     { 
      background-color:#3064c8; 
     } 
     ul#HorizontalNavigationMenu ul#PayRollSubMenu li:hover>a 
     { 
      background-color:#f83000; 
      display:block; 
     } 


     ul#HorizontalNavigationMenu ul#MastersSubMenu 
     { 
      /*outline:solid blue 2px;*/ 
      position:relative; 
      display:none; 
      width:175px; 
      top:1px; 
     } 
     ul#HorizontalNavigationMenu ul#MastersSubMenu a 
     { 
      display:block; 
      width:175px; 
      background-color:#f89800; 
     } 
     ul#HorizontalNavigationMenu>li:hover ul#MastersSubMenu 
     { 
      display:block; 
     } 
     ul#HorizontalNavigationMenu ul#MastersSubMenu li:hover>a 
     { 
      background-color:#f83000; 
      display:block; 
     } 


     ul#HorizontalNavigationMenu ul#EnquirySubMenu 
     { 
      /*outline:solid blue 2px;*/ 
      position:relative; 
      display:none; 
      width:175px; 
      top:1px; 
     } 
     ul#HorizontalNavigationMenu ul#EnquirySubMenu a 
     { 
      display:block; 
      width:175px; 
      background-color:#f89800; 
     } 
     ul#HorizontalNavigationMenu>li:hover ul#EnquirySubMenu 
     { 
      display:block; 
     } 
     ul#HorizontalNavigationMenu ul#EnquirySubMenu li:hover>a 
     { 
      background-color:#f83000; 
      display:block; 
     } 



     ul#HorizontalNavigationMenu ul#StudentDetailsSubMenu 
     { 
      /*outline:solid blue 2px;*/ 
      position:relative; 
      display:none; 
      width:175px; 
      top:1px; 
     } 
     ul#HorizontalNavigationMenu ul#StudentDetailsSubMenu a 
     { 
      display:block; 
      width:175px; 
      background-color:#f89800; 
     } 
     ul#HorizontalNavigationMenu>li:hover ul#StudentDetailsSubMenu 
     { 
      display:block; 
     } 
     ul#HorizontalNavigationMenu ul#StudentDetailsSubMenu li:hover>a 
     { 
      background-color:#f83000; 
      display:block; 
     } 


     /* -------Styling the Blue Gradient---------- */ 
     div#BlueGradient 
     { 
      position:absolute; 
      display:block; 
      height:30px; 
      width:100%; 
      border:solid blue 1px; 
      z-index:-1; 
     } 





     /*--------Styling the StaffDetails--------*/ 
     div#StaffDetails 
     { 
      display:block; 
      position:absolute; 
      width:100%; 
      height:400px; 
      top:200px; 
      border:solid red 1px; 
      background-color:#d0dcc0; 
      z-index:0; 

     } 

     div#StaffDetails div#StaffDetailsBanner 
     { 
      display:block; 
      height:30px; 
      line-height:30px; 
      color:white; 
      background-color:#3098c8; 
      text-align:center; 
      font-family:Calibri; 
      font-weight:bold; 
     } 

     .GridViewTable 
     { 
      border-collapse:collapse; 
      height:25px; 
      width:100%; 
      font-family:Segoe UI; 
      font-size:11px; 
      font-weight:bold; 
      position:absolute; 
      top:30px; 
     } 
     .TableHeadingRow 
     { 
      background-color:#688890; 
      color:white; 
      height:30px; 
      text-align:center; 
      font-weight:bold; 
      font-size:13px; 
      border:solid white 1px; 
      font-family:'Segoe UI'; 
     } 
     .TableRow 
     { 
      height:25px; 
      color:#1b469d; 
      border:solid white 1px; 
      padding-left:5px; 
      background-color:#d0dcc0; 
      font-family:'Segoe UI'; 
      font-size:11px; 
      text-align:center; 
      font-weight:bold; 
     } 

     .BlueButton 
     { 
      background:#018788; 
      width:75px; 
      height:25px; 
      color:white; 
      border:solid white 2px; 
      font-family:Segoe UI; 
      font-weight:bold; 
     } 
     .BlueButton:hover 
     { 
      cursor:pointer; 
     } 



    </style> 

    </head> 
    <body> 
<form id="StaffDetailsForm" runat="server" method="get" > 
<!-- *************Kohinoor Banner****************** --> 
    <div id="KohinoorBanner"> 
     <asp:Image runat="server" ID="KohinoorLogoImage" ImageUrl="~/Images/Kohinoor.jpg" alt="KohinoorLogo"></asp:Image> 
     <div id="GoogleSearchSection"></div> 
     <div id="Date"></div> 
    </div> 



    <!-- *************Kohinoor Horizontal Navigation Menu****************** --> 
    <div id="KohinoorNavigationMenu"> 
     <ul id="HorizontalNavigationMenu"> 
      <li> 
       <a href="#">&nbsp;--Masters--</a> 
       <ul id="MastersSubMenu"></ul> 
      </li> 
      <li> 
       <a href="#">&nbsp;--Enquiry--</a> 
       <ul id="EnquirySubMenu"> 
        <li><a href="EnquiryRegistrationSystem.aspx" >&nbsp;>Registration</a></li> 
        <li><a href="FollowUpProcessSystem.aspx" >&nbsp;>>Followup</a></li> 

       </ul> 
      </li> 
      <li> 
       <a href="#">&nbsp;--Student Details--</a> 
       <ul id="StudentDetailsSubMenu"> 
        <li><a href="StudentPhotoUploadMonitoringSystem.aspx" >&nbsp;>> Student Photo</a></li> 





       </ul> 
      </li> 
      <li> 
       <a href="#">&nbsp;--PayRoll--</a> 
       <ul id="PayRollSubMenu"> 
        <li><a href="StaffRegistrationSystem.aspx" >&nbsp;>> Staff Details</a></li> 
        <li><a href="StaffSalaryMonitoringsystem.aspx" >&nbsp;>> Salary Details</a></li> 
        <li><a href="StaffPhotoManagementSystem.aspx">&nbsp;>> Staff Photo</a></li> 
        <li><a href="StaffWorkProfileSystem.aspx" >&nbsp;>> Work Profile</a></li> 
        <li><a href="StaffLeaveMonitoringSystem.aspx">&nbsp;>> Leave Details</a></li> 

       </ul> 
      </li> 
      <li><a href="#">&nbsp;--Reports--</a></li> 
      <li><a href="#">&nbsp;--Live Conversation--</a></li> 
      <li><a href="#">&nbsp;--Logout--</a></li> 
     </ul> 
    </div> 





    <!-- *************Kohinoor Blue Gradient****************** --> 
    <div id="BlueGradient">Blue Gradient</div> 



    <!-- *************Staff Details****************** --> 
    <asp:HiddenField runat="server" ID="SearchType_HiddenField" Value="" /> 
    <asp:HiddenField runat="server" ID="NameOrNo_HiddenField" Value="" /> 
    <asp:HiddenField runat="server" ID="EmployeeCode_HiddenField" Value="" /> 
    <asp:HiddenField runat="server" ID="FirstName_HiddenField" Value="" /> 
    <asp:HiddenField runat="server" ID="FirstPage" Value="true" /> 
    <div id="StaffDetails"> 
     <div id="StaffDetailsBanner"> 
      Staff Details 
     </div> 
     <div id="StaffDetailsContent"> 
      <asp:SqlDataSource runat="server" 
       ID="SqlDataSource_FirstName" 
       ConnectionString="Data Source=NIRMIT-PC\SQLEXPRESS;Initial Catalog=KohinoorDatabaseTrial3;Integrated Security=True" 
       SelectCommand="SELECT SPD.emp_code, SN.first_name, SN.middle_name, SN.last_name, SPD.blood_group, SPD.religion, SPD.DOB, SPD.contact_no1, SPD.contact_no2, SED.highest_qualification, SOD.designation, SOD.aggrement_type, SOD.doj, SOD.pf_no 
       FROM StaffPersonalDetails AS SPD 
       LEFT OUTER JOIN StaffName AS SN 
       ON SPD.emp_code = SN.emp_code 
       LEFT OUTER JOIN StaffOfficialDetails AS SOD 
       ON SPD.emp_code = SOD.emp_code 
       LEFT OUTER JOIN StaffEducationalDetails AS SED 
       ON SPD.emp_code = SED.emp_code 
       WHERE SN.first_name LIKE '%' + @FirstName + '%'"> 
       <SelectParameters> 
        <asp:ControlParameter ControlID="FirstName_HiddenField" Name="FirstName" /> 
       </SelectParameters> 
      </asp:SqlDataSource> 
      <asp:SqlDataSource runat="server" 
       ID="SqlDataSource_EmployeeCode" 
       ConnectionString="Data Source=NIRMIT-PC\SQLEXPRESS;Initial Catalog=KohinoorDatabaseTrial3;Integrated Security=True" 
       SelectCommand="SELECT SPD.emp_code, SN.first_name, SN.middle_name, SN.last_name, SPD.blood_group, SPD.religion, SPD.DOB, SPD.contact_no1, SPD.contact_no2, SED.highest_qualification, SOD.designation, SOD.aggrement_type, SOD.doj, SOD.pf_no 
       FROM StaffPersonalDetails AS SPD 
       LEFT OUTER JOIN StaffName AS SN 
       ON SPD.emp_code = SN.emp_code 
       LEFT OUTER JOIN StaffOfficialDetails AS SOD 
       ON SPD.emp_code = SOD.emp_code 
       LEFT OUTER JOIN StaffEducationalDetails AS SED 
       ON SPD.emp_code = SED.emp_code 
       WHERE SPD.emp_code = @EmployeeCode"> 
       <SelectParameters> 
        <asp:ControlParameter ControlID="EmployeeCode_HiddenField" Name="EmployeeCode" /> 
       </SelectParameters> 
      </asp:SqlDataSource> 
      <asp:GridView runat="server" 
       ID="StaffDetailsGridView" 
       Width="100%" 
       AllowPaging="true" 
       PageSize="10" 
       AutoGenerateColumns="False" 
       EmptyDataText="No Result Found" 
       EnablePersistedSelection="True" 
       DataKeyNames="emp_code" 
       CssClass="GridViewTable"> 
       <Columns> 
        <asp:BoundField DataField="emp_code" HeaderText="Emp Code"/> 
        <asp:TemplateField HeaderText="Student Name"> 
         <ItemTemplate> 
          <asp:HyperLink ID="StaffNameHyperlink" NavigateUrl='<%# "~/StaffInformationBasicSalaryDetailAdd.aspx?EmpCode=" + Eval("emp_code") %>' runat="server"><asp:Label runat="server" ID="FirstNameLabel" Text='<%# Eval("first_name") + " " + Eval("middle_name") + " " + Eval("last_name")%>'></asp:Label></asp:HyperLink> 
         </ItemTemplate> 
        </asp:TemplateField> 
        <asp:BoundField DataField="blood_group" HeaderText="Blood Grp"/> 
        <asp:BoundField DataField="religion" HeaderText="Religion"/> 
        <asp:TemplateField HeaderText="DOB"> 
         <ItemTemplate> 
          <asp:Label runat="server" Text='<%# Eval("DOB").ToString().Substring(0,11)%>'></asp:Label> 
         </ItemTemplate> 
        </asp:TemplateField> 
        <asp:BoundField DataField="contact_no1" HeaderText="Contact No" /> 
        <asp:BoundField DataField="highest_qualification" HeaderText="Qualification" /> 
        <asp:BoundField DataField="designation" HeaderText="Designation" /> 
        <asp:BoundField DataField="aggrement_type" HeaderText="Aggrement Type" /> 
        <asp:TemplateField HeaderText="Date of Join"> 
         <ItemTemplate> 
          <asp:Label runat="server" Text='<%# Eval("doj").ToString()%>'></asp:Label> 
         </ItemTemplate> 
        </asp:TemplateField> 
        <asp:BoundField DataField="pf_no" HeaderText="Pf No" /> 
       </Columns> 
       <HeaderStyle CssClass="TableHeadingRow" /> 
       <RowStyle CssClass="TableRow" /> 
      </asp:GridView> 
     </div> 
    </div> 
</form> 

後面的代碼

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 

public partial class StaffDetailsForStaffSalaryMonitoringSystemAdd : System.Web.UI.Page 
{ 
    DropDownList SearchType_DropDownList; 
    String SearchType_Selected; 
    TextBox NameOrNo_TextBox; 
    String NameOrNo_Selected; 
    protected void Page_Load(object sender, EventArgs e) 
    { 
    if(FirstPage.Value.ToLower().Trim().Equals("true")) 
    { 
     SearchType_DropDownList = (DropDownList)PreviousPage.FindControl("SearchType"); 
     SearchType_Selected = SearchType_DropDownList.SelectedItem.Text; 
     NameOrNo_TextBox = (TextBox)PreviousPage.FindControl("NameOrNo"); 
     NameOrNo_Selected = NameOrNo_TextBox.Text; 

     SearchType_HiddenField.Value = SearchType_Selected; 
     NameOrNo_HiddenField.Value = NameOrNo_Selected; 
     if (SearchType_Selected.Equals("Employee Code")) 
     { 
      EmployeeCode_HiddenField.Value = NameOrNo_Selected; 
      StaffDetailsGridView.DataSourceID = SqlDataSource_EmployeeCode.ID; 
     } 
     if (SearchType_Selected.Equals("Name")) 
     { 
      FirstName_HiddenField.Value = NameOrNo_Selected; 
      StaffDetailsGridView.DataSourceID = SqlDataSource_FirstName.ID; 
     } 
     StaffDetailsGridView.DataBind(); 
     FirstPage.Value = "false"; 
    } 


} 

//protected void StaffDetailsGridView_PageIndexChanging(object sender, GridViewPageEventArgs e) 
//{ 
// //StaffDetailsGridView.PageIndex = e.NewPageIndex; 
// //SearchType_Selected = SearchType_HiddenField.Value; 
// //NameOrNo_Selected = NameOrNo_HiddenField.Value; 
// //if (SearchType_Selected.Equals("Employee Code")) 
// //{ 
// // EmployeeCode_HiddenField.Value = NameOrNo_Selected; 
// // StaffDetailsGridView.DataSource = SqlDataSource_EmployeeCode; 
// //} 
// //if (SearchType_Selected.Equals("Name")) 
// //{ 
// // FirstName_HiddenField.Value = NameOrNo_Selected; 
// // StaffDetailsGridView.DataSource = SqlDataSource_FirstName; 
// //} 
// //StaffDetailsGridView.DataBind(); 
//} 
} 

對不起,把它放在這裏是因爲它難道不適合在評論 這是我在回發時的鏈接(即點擊電網

//localhost:55415/StaffDetailsForStaffSalaryMonitoringSystemAdd.aspx?__EVENTTARGET=StaffDetailsGridView & __EVENTARGUMENT =頁%243 & __VIEWSTATE = 9z9ztJ5%2Ftwu4G%的2Fe%2Fu1hJUeTt4CsKw0J6Iv%2BR0ruYcADC572F%2B9bgbQrdk6T8l%2FbEMDhBagjhIKaGlAWq%2BkUKGgEvIoEHoqCxPRn4lfMe4l2K8ZLl%某些頁碼後2FkTUwx20NhOWW9Gr8heXkjbEVz8cS1zhxrSW7s28OZFAs20x8vi2EmOrSlFUKjeYDShlfDgDz .....

回答

1

您是否嘗試過在你的web配置加入這一行

 <system.web> 
     <httpRuntime maxQueryStringLength="32768" maxUrlLength="65536"/> 

    </system.web> 

    <system.webServer> 
    <security> 
     <requestFiltering> 
     <requestLimits maxQueryString="2097151"/> 
    </requestFiltering> 
    </security> 
</system.webServer> 

看來你的查詢字符串變得牛逼OO長分頁時,因爲您有長的類的名稱,如「StaffDetailsForStaffSalaryMonitoringSystemAdd」。你的URL將分頁

<a href="javascript:__doPostBack('ctl00$ContentPlaceholder$StaffDetailsForStaffSalaryMonitoringSystemAdd$StaffDetailsGridView','Page$2')">2</a> 

當成爲這樣的事情因此error.Increase在webconfig你的口味設置的值。

+0

我試着按照你的說法(配置我的網絡配置文件),但仍然收到相同的錯誤。接下來,我甚至將我的類的名稱從「StaffDetailsForStaffSalaryMonitoringSystemAdd」減少到「StaffDetailsS​​SMSAdd」,但它仍然給我帶來了同樣的錯誤。 – user3529789

+0

此外我甚至將maxQueryStringLength和maxUrlLength的值設置爲「2097151」,這是它們可以採用的最大值,但仍然會出現相同的錯誤。我能做些什麼來完成這項工作? – user3529789

+0

我已經更新了我的答案。嘗試在您的Web配置中使用這兩種設置的組合。 –