asp.net Repeater 數(shù)據(jù)綁定代碼
更新時(shí)間:2010年03月30日 13:14:50 作者:
asp.net Repeater 數(shù)據(jù)綁定代碼
ASPX頁面的Repeater控件:
<asp:Repeater ID="IndexTopMain" runat="server">
<HeaderTemplate><!--頭-->
<ul>
</HeaderTemplate>
<ItemTemplate><!--中間循環(huán)部分-->
<li> • <a href="AritcleDisplay.aspx?id=<%#Eval("id") %>" title="<%#Eval("title") %>" target="_blank"><%#Eval("title").ToString().Length>30?Eval("title").ToString().Substring(0,30)+"...":Eval("title")%></a></li>
</ItemTemplate>
<FooterTemplate><!--尾-->
</ul>
</FooterTemplate>
</asp:Repeater>
CS文件的綁定
string indexTopMainStr = "select top 9 id,title from Table order by ID desc";
SqlDataAdapter rst = new SqlDataAdapter(indexTopMainStr,conn);
conn.Open();
DataSet rdt = new DataSet();
rst.Fill(rdt);
IndexTopMain.DataSource = rdt;//數(shù)據(jù)綁定
IndexTopMain.DataBind();
conn.Close();
復(fù)制代碼 代碼如下:
<asp:Repeater ID="IndexTopMain" runat="server">
<HeaderTemplate><!--頭-->
<ul>
</HeaderTemplate>
<ItemTemplate><!--中間循環(huán)部分-->
<li> • <a href="AritcleDisplay.aspx?id=<%#Eval("id") %>" title="<%#Eval("title") %>" target="_blank"><%#Eval("title").ToString().Length>30?Eval("title").ToString().Substring(0,30)+"...":Eval("title")%></a></li>
</ItemTemplate>
<FooterTemplate><!--尾-->
</ul>
</FooterTemplate>
</asp:Repeater>
CS文件的綁定
復(fù)制代碼 代碼如下:
string indexTopMainStr = "select top 9 id,title from Table order by ID desc";
SqlDataAdapter rst = new SqlDataAdapter(indexTopMainStr,conn);
conn.Open();
DataSet rdt = new DataSet();
rst.Fill(rdt);
IndexTopMain.DataSource = rdt;//數(shù)據(jù)綁定
IndexTopMain.DataBind();
conn.Close();
您可能感興趣的文章:
- ASP.NET repeater添加序號(hào)列的方法
- asp.net Repeater取得CheckBox選中的某行某個(gè)值的c#寫法
- asp.net repeater手寫分頁實(shí)例代碼
- asp.net Repeater之非常好的數(shù)據(jù)分頁
- asp.net中讓Repeater和GridView支持DataPager分頁
- asp.net Repeater 數(shù)據(jù)綁定的具體實(shí)現(xiàn)(圖文詳解)
- asp.net 遍歷repeater中的控件的幾種方式
- asp.net下Repeater使用 AspNetPager分頁控件
- asp.net repeater實(shí)現(xiàn)批量刪除
- asp.net Repeater控件的說明及詳細(xì)介紹及使用方法
- JQuery實(shí)現(xiàn)Repeater無刷新批量刪除(附后臺(tái)asp.net源碼)
- 決定何時(shí)使用 DataGrid、DataList 或 Repeater(ASP.NET 技術(shù)文章)
- ASP.NET筆記之 Repeater的使用
- asp.net DataList與Repeater用法區(qū)別
- 詳解ASP.NET數(shù)據(jù)綁定操作中Repeater控件的用法
相關(guān)文章
IIS故障(Connections_Refused)問題分析及處理
這幾天某地市Web服務(wù)器連續(xù)多次出現(xiàn)故障問題(Connections_Refused),正好借這個(gè)案例向大家詳細(xì)介紹下,需要了解的朋友可以參考下2012-12-12asp.net顯示圖片到指定的Image控件中 具體實(shí)現(xiàn)
這篇文章介紹了asp.net顯示圖片到指定的Image控件中 具體實(shí)現(xiàn),有需要的朋友可以參考一下2013-11-11Asp.Net其他頁面如何調(diào)用Web用戶控件寫的分頁
這篇文章主要介紹了Asp.Net其他頁面如何調(diào)用Web用戶控件寫的分頁,需要的朋友可以參考下2014-05-05.NET客戶端實(shí)現(xiàn)Redis中的管道(PipeLine)與事物(Transactions)
本文主要介紹了.NET客戶端實(shí)現(xiàn)Redis中的管道(PipeLine)與事物(Transactions)的相關(guān)知識(shí)。具有很好的參考價(jià)值,下面跟著小編一起來看下吧2017-03-03數(shù)據(jù)庫開發(fā)總結(jié)(ADO.NET小結(jié))
數(shù)據(jù)庫開發(fā)總結(jié)(ADO.NET小結(jié))...2006-12-12ASP.NET MVC5驗(yàn)證系列之Remote Validation
這篇文章主要為大家詳細(xì)介紹了ASP.NET MVC5驗(yàn)證系列之Remote Validation,感興趣的小伙伴們可以參考一下2016-07-07ASP.NET連接sql2008數(shù)據(jù)庫的實(shí)現(xiàn)代碼
這篇文章主要介紹了ASP.NET連接sql2008數(shù)據(jù)庫的實(shí)現(xiàn)代碼,需要的朋友可以參考下2015-01-01