ASP.NET2.0中有没有可分页又可以多列显示的控件?
我想做一个成可以同时显示多列多行 每个小板块显示一些图片 图片过多的时候可以分页 谢谢
[解决办法]
DataList 控件可以实现,不过分页要自已写
参考如下:
------------------------------前台:-------------------------------
<asp:DataList ID= "DataList1 " runat= "server " RepeatColumns= "2 " OnItemCommand= "DataList1_ItemCommand "
Width= "550px " OnItemDataBound= "DataList1_ItemDataBound ">
<ItemTemplate>
<table id= "tbl_container " runat= "server " border= "0 " align= "center " width= "280 " height= "170 ">
<tr>
<td align= "right " style= "width: 278px " colspan= "2 ">
<asp:Label ID= "LblCardName " runat= "server " Text= ' <%# DataBinder.Eval(Container.DataItem, "CardName ") %> '
Font-Bold= "True "> </asp:Label> </td>
</tr>
<tr>
<td style= "width: 278px " colspan= "2 ">
<asp:Label ID= "LblType " runat= "server " Visible= "false " Text= ' <%#Convert.ToInt32(DataBinder.Eval(Container.DataItem, "CardType ")).ToString() %> '> </asp:Label>
</td>
</tr>
<tr>
<td width= "35% " valign= "bottom ">
面值: <asp:Label CssClass= "DeleteLine " ID= "Label2 "
runat= "server " Text= ' <%# Convert.ToInt32(DataBinder.Eval(Container.DataItem, "CardPrice ")).ToString()%> '> </asp:Label> 元
</td>
<td valign= "bottom " align= "left ">
销售价格: <asp:Label ID= "LblFactPrice " runat= "server " Text= ' <%# Convert.ToInt32(DataBinder.Eval(Container.DataItem, "CardFactPrice ")).ToString() %> '> </asp:Label> 元 </td>
</tr>
<tr>
<td colspan= "2 ">
使用期: <asp:Label ID= "Label4 " runat= "server " Text= ' <%# DataBinder.Eval(Container.DataItem, "CardDayAmount ") %> '> </asp:Label> 天
</td>
</tr>
<tr>
<td style= "width: 278px " align= "right " colspan= "2 ">
<asp:LinkButton CssClass= "origA " ID= "ButtonPopedom " CommandArgument= ' <%# DataBinder.Eval(Container.DataItem, "studyCardID ")%> '
Text= "查看权限 " CommandName= "Look " runat= "server "> </asp:LinkButton>
<asp:LinkButton ID= "ButtonBuy " runat= "server " CommandArgument= ' <%# DataBinder.Eval(Container.DataItem, "studyCardID ")%> '
Text= "放入购物车 " CssClass= "origA " CommandName= "Resquest " />
</td>
</tr>
</table>
<table border= "0 ">
<tr height= "5 ">
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
<tr>
<td align= "center ">
<asp:HyperLink ID= "HyperLinkStart " runat= "server "> 首页 </asp:HyperLink>
<asp:HyperLink ID= "lnkPrev " runat= "server "> 上一页 </asp:HyperLink>
<asp:HyperLink ID= "lnkNext " runat= "server "> 下一页 </asp:HyperLink>
<asp:HyperLink ID= "HyperLinkEnd " runat= "server "> 尾页 </asp:HyperLink>
当前: <asp:DropDownList ID= "ddl_CurrentPage " runat= "server " AutoPostBack= "True " OnSelectedIndexChanged= "ddl_CurrentPage_SelectedIndexChanged ">
</asp:DropDownList> 页
</td>
</tr>
-----------------------------后台=-------------------------------------------
//分页
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = dt.DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 10;
int CurPage;
if (Request.QueryString[ "Page "] != null)
CurPage = Convert.ToInt32(Request.QueryString[ "Page "]);
else
CurPage = 1;
objPds.CurrentPageIndex = CurPage - 1;
//计算总共有多少页
//取整
int iPageCount = dt.Rows.Count / objPds.PageSize;
if (dt.Rows.Count % objPds.PageSize > 0)
iPageCount = iPageCount + 1;
if (!objPds.IsFirstPage)
HyperLinkStart.NavigateUrl = Request.CurrentExecutionFilePath + "?Page= " + Convert.ToString(1);
if (!objPds.IsFirstPage)
lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page= " + Convert.ToString(CurPage - 1);
if (!objPds.IsLastPage)
lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page= " + Convert.ToString(CurPage + 1);
if (!objPds.IsLastPage)
HyperLinkEnd.NavigateUrl = Request.CurrentExecutionFilePath + "?Page= " + Convert.ToString(iPageCount);
//
this.DataList1.DataSource = objPds;
this.DataList1.DataBind();
[解决办法]
DataList 1.1里面就可以了。