日期:2014-05-20 浏览次数:20797 次
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate> <table><tr> <td style="width:40%"> <asp:Label ID="lblImg_id" runat="server" Text='<%#Eval("img_id") %>' Visible="false"></asp:Label><img src='../<%#Eval("img_url") %>' height="20px"/></td> <td style="width:10%"> <%#Eval("pic_type") %> //这个是YSYS_Type当中的字段,其他字段都是YSYS_DYTPImg当中的字段 </td> <td><%#Eval("img_name") %></td> <td style="width:10%"> <a href='<%#Eval("img_id","DetailDYTPImg.aspx?img_id={0}") %>'>修改</a></td> </tr></table> </ItemTemplate> </asp:Repeater> <webdiyer:AspNetPager ID="aspPages" runat="server" HorizontalAlign="Center" onpagechanging="aspPages_PageChanging"> </webdiyer:AspNetPager>
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // YSYSDataContext ysys = new YSYSDataContext();//这个是linq to sql自动生成的代码 // IList<YSYS_DYTPImg> list = ysys.YSYS_DYTPImg.ToList(); //aspPages.RecordCount = list.Count; //PagedDataSource pd = new PagedDataSource(); //pd.DataSource = list; //pd.AllowPaging = true; //pd.PageSize = this.aspPages.PageSize; //pd.CurrentPageIndex = 0; //this.Repeater1.DataSource = pd; //this.Repeater1.DataBind(); } } protected void aspPages_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e) { }
YSYSDataContext ysys = new YSYSDataContext(); // IList<YSYS_DYTPImg> list = ysys.YSYS_DYTPImg.ToList(); var list = (from i in ysys.YSYS_DYTPImg join t in ysys.YSYS_Type on i.Pic_Id equals p.Pic_ID select new Temp { ImgId=i.ImgId, Img_Url=i.Img_Url, Pic_Id=i.Pic_Id, Img_Name=i.Img_Name, Pic_Type= t.Pic_Type }).ToList() aspPages.RecordCount = list.Count(); PagedDataSource pd = new PagedDataSource(); pd.DataSource = list; pd.AllowPaging = true; pd.PageSize = this.aspPages.PageSize; pd.CurrentPageIndex = 0; this.Repeater1.DataSource = pd; this.Repeater1.DataBind(); public class Temp { public int ImgId{get;set;} public string Img_Url{get;set;} public int Pic_Id{get;set;} public string Img_Name{get;set;} public string Pic_Type{get;set;} }