編輯:現在工作,見下文。ASP.Net Gridview分頁,pageindex始終== 0
大家好,
有我的ASP.Net 3.5應用程序一個小問題。我試圖讓程序拿起被點擊的頁碼。我正在使用內置的AllowPaging =「True」函數的ASP.Net。這是從來沒有不代碼是相同的,所以在這裏它是:
ASP.Net:
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="Vertical" Width="960px" AllowSorting="True"
EnableSortingAndPagingCallbacks="True" AllowPaging="True" PageSize="25" >
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
C#:
var fillTable = from ft in db.IncidentDatas
where ft.pUserID == Convert.ToInt32(ClientList.SelectedValue.ToString())
select new
{
Reference = ft.pRef.ToString(),
Date = ft.pIncidentDateTime.Value.Date.ToShortDateString(),
Time = ft.pIncidentDateTime.Value.TimeOfDay,
Premesis = ft.pPremises.ToString(),
Latitude = ft.pLat.ToString(),
Longitude = ft.pLong.ToString()
};
if (fillTable.Count() > 0)
{
GridView1.DataSource = fillTable;
GridView1.DataBind();
var IncidentDetails = fillTable.ToList();
for (int i = 0; i < IncidentDetails.Count(); i++)
{
int pageno = GridView1.PageIndex;
int pagenostart = pageno * 25;
if (i >= pagenostart && i < (pagenostart + 25))
{
//Processing
}
}
}
任何想法,爲什麼GridView1.PageIndex總是= 0?事情是,處理對於網格視圖正常工作....它將始終轉到正確的分頁頁面,但當我嘗試獲取數字時,它始終爲0。幫幫我!
是啊,我已經試過這個,仍然是0. – 2010-05-26 12:06:52
你的綁定代碼位於哪個事件中? – AxelEckenberger 2010-05-26 12:31:07