我的GridView的:
< ASP:GridView控件ID =gridView1=服务器的cellpadding =4AllowPaging =真,每页=5emptydatatext =无可用数据。
的CssClass =数据网格
前景色=#333333网格=无
onrowcreated =gridView1_RowCreated
onpageindexchanging =gridView1_PageIndexChanging>
< AlternatingRowStyle背景色=白前景色=#284775/>
< EditRowStyle背景色=#999999/>
< FooterStyle背景色=#5D7B9D字体,粗体为真前景色=白/>
< HeaderStyle背景色=#5D7B9D字体,粗体为真前景色=白/>
< PagerStyle背景色=#284775前景色=白HorizontalAlign =中心/>
< RowStyle背景色=#F7F6F3前景色=#333333/>
< SelectedRowStyle背景色=#E2DED6字体,粗体为真前景色=#333333/>
< SortedAscendingCellStyle背景色=#E9E7E2/>
< SortedAscendingHeaderStyle背景色=#506C8C/>
< SortedDescendingCellStyle背景色=#FFFDF8/>
< SortedDescendingHeaderStyle背景色=#6F8DAE/>
< / ASP:GridView控件>
和我的codebehind:
保护无效gridView1_PageIndexChanging(对象发件人,GridViewPageEventArgs E)
{
gridView1.PageIndex = e.NewPageIndex;
BindDataGrid();
}
保护无效BindDataGrid()
{
的DataSet ds为新的DataSet();
DS = dbM.GetInfo(姓名,MOBILEPHONE,INFO1); //获取信息,以BD和保存DS
gridView1.DataSource = DS;
gridView1.DataBind();
}
和寻呼是行不通的。它示出了第一5行,但没有显示寻呼的数目
What's错???
请帮忙
感谢
解决方案 使用**PageIndexChanged**
保护无效gridView1_PageIndexChanged(对象发件人,GridViewPageEventArgs E)
{
尝试
{
gridView1.PageIndex = e.NewPageIndex;
BindDataGrid();
;
}
赶上(例外前)
{
回复于(ex.Message);
}
}
My gridView:
<asp:GridView ID="gridView1" runat="server" CellPadding="4" AllowPaging="true" PageSize="5" emptydatatext="No data available."
CssClass="datagrid"
ForeColor="#333333" GridLines="None"
onrowcreated="gridView1_RowCreated"
onpageindexchanging="gridView1_PageIndexChanging">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
And my codebehind:
protected void gridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridView1.PageIndex = e.NewPageIndex;
BindDataGrid();
}
protected void BindDataGrid()
{
DataSet ds = new DataSet();
ds = dbM.GetInfo(name, mobilePhone, info1); //get info to BD and save in "ds"
gridView1.DataSource = ds;
gridView1.DataBind();
}
and the "Paging" does not work. It shows the first 5 rows, but does not show the number of paging
What´s wrong???
Please help
thanks
解决方案 Use **"PageIndexChanged"**
protected void gridView1_PageIndexChanged(object sender, GridViewPageEventArgs e)
{
try
{
gridView1.PageIndex = e.NewPageIndex;
BindDataGrid();
;
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}