.net(C#) DataList数字分页问题..在线等
请问分页码怎么显示不出来,求教 我彩用的是数字分页 如 123456789
ASPX页代码
<asp:DataList ID="Data_p" RepeatColumns="4" Width="100%" RepeatDirection="Horizontal" runat="server" DataKeyField="id" >
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
姓名:<%# Eval("name") %><%# Eval("id") %><br />
电话:<%# Eval("tel") %><br />
</ItemTemplate>
<FooterTemplate>
<asp:PlaceHolder ID="ph" runat="server" Visible="true" ></asp:PlaceHolder>
</FooterTemplate>
<EditItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" />
</asp:DataList>
C# code
ASPX.cs代码
private void datalist_pagecommand(object sender,DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Footer)
{
PlaceHolder ph = (PlaceHolder)e.Item.FindControl("ph");
db pdb = new db();
for (int i = 0; i < pdb.pgs().PageCount; i++)
{
HyperLink h=new HyperLink();
Literal l = new Literal();
int n = i + 1;
h.Text = n.ToString();
h.ID=n.ToString();
h.NavigateUrl = "datelist2.aspx?page=" + i.ToString();
l.Text =" ";
ph.Controls.Add(h);
ph.Controls.Add(l);
}
}
}
------解决方案--------------------用aspnetpager控件
http://www.webdiyer.com/AspNetPager/default.aspx
------解决方案--------------------private void datalist_pagecommand(object sender,DataListItemEventArgs e)
-->改成这个
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
------解决方案--------------------private void datalist_pagecommand(object sender,DataListItemEventArgs e)
不是这个事件
楼上正解 ItemDataBound