兄弟们,我用vs.net2003的datalist控件已经将数据表中的全部记录输出来了,想实现:多行多列输出,现在结果能出来,也能分页了,但为什么总显示 一行三列啊??不知如何,该调的属性都调了,我用的是模板前台代码如何:
<asp:DataList id="DataList1" runat="server" style="Z-INDEX: 102; LEFT: 64px; POSITION: absolute; TOP: 136px" RepeatColumns="8" RepeatDirection="Horizontal">
<ItemTemplate>
<table width="160" height="180" border="0" align="center" cellpadding="0" cellspacing="0"
id="tablemain">
<tr>
<td width="140" height="20">
<div align="left">用户名:<a href='ReadTemp.aspx?ID=<%# DataBinder.Eval(Container.DataItem,"ID") %>' target="_blank"><%# DataBinder.Eval(Container.DataItem,"ID") %></a></div>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
<HeaderTemplate > <span><%=FSSoft.Web.UI.Language.Msg("c00301")%></span> </HeaderTemplate>
<HeaderStyle CssClass="DataListHeader" HorizontalAlign="Center" Font-Bold=True/>
<ItemStyle CssClass="ListCellRow" Height="40px" BackColor="#FCFFEE" Width="25%"/> <ItemTemplate>
<table width="100%" height="100%" cellpadding="0" cellspacing="0" border=0 >
<tr >
<td onClick="changecolor();this.style.backgroundColor='#F3F2F4'" id="ret<%#Container.ItemIndex%>" title="" style="cursor:hand; width:100%;">
<a href="#" onclick="javascript:MM_showModalDialogBrWindow('yaopin_leibie_into.aspx?act=edit&f_ItemNo=<%# DataBinder.Eval(Container.DataItem, "f_ItemNo")%>','obj','center=yes;status=0;dialogHeight=250px;dialogWidth=500px;scroll=yes;');location.replace('yaopin_leibie_list.aspx');" title="Edit">(<%#Eval("f_MedicationTypeName")%>) (<%#Eval("f_MedicationTypeKName")%>)</a>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
照着我的这个试试
private void Page_Load(object sender, System.EventArgs e)
{
AspNetPager1.RecordCount=mySocut.ExecuteScalar("SELECT COUNT(*) FROM userinfo");//统计目标数据一共有多少行
GetData();//页面一load的话,自动调用GetData()函数,以便显示数据 if(!Page.IsPostBack)
{ AspNetPager1.RecordCount=mySocut.ExecuteScalar("SELECT COUNT(*) FROM userinfo");//统计目标数据一共有多少行
GetData();//页面一load的话,自动调用GetData()函数,以便显示数据 BindData();
}
} private void BindData()
{
AspNetPager1.RecordCount=mySocut.ExecuteScalar("SELECT COUNT(*) FROM userinfo");//统计目标数据一共有多少行
GetData();//页面一load的话,自动调用GetData()函数,以便显示数据
AspNetPager1.Font.Size=2;
AspNetPager1.CustomInfoText="记录总数:<font color=\"blue\"><b>"+AspNetPager1.RecordCount.ToString()+"</b></font>";
AspNetPager1.CustomInfoText+=" 总页数:<font color=\"blue\"><b>"+AspNetPager1.PageCount.ToString()+"</b></font>";
AspNetPager1.CustomInfoText+=" 当前页:<font color=\"red\"><b>"+AspNetPager1.CurrentPageIndex.ToString()+"</b></font>";
} public void GetData()
{
int intStart=AspNetPager1.PageSize*(AspNetPager1.CurrentPageIndex-1);//要读取的开始行,这句是如何计算的,不用关心。因为他基本上算是组件的一个计算公式。当然,如果你愿意花精力去研究,那也是可以的。
int intNum=AspNetPager1.PageSize;//一共要读取多少行,请在.aspx页设置PageSize的大小
DataSet ds=mySocut.GetDataSet("SELECT * FROM userinfo",intStart,intNum,"myDS1");//myDS1是虚拟表名,名字可以随便起。 DataList1.DataSource=ds;//设置DataGrid的数据源
DataList1.DataBind();//最后绑定数据到DataGrid
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void AspNetPager1_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
{
AspNetPager1.CurrentPageIndex=e.NewPageIndex;//这句用于获取当前分页index索引值,以便正常实现分页定位 BindData(); }