编辑:现在工作,见下文。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