ASP.NET repeater添加序號列的方法
更新時間:2012年11月23日 11:24:32 作者:
在項目開發(fā)過程中,會經常遇到ASP.NET repeater控件添加序號列,有些新手可能還不會,網(wǎng)上搜集整理了一些,需要的朋友可以參考下
在項目開發(fā)過程中,會經常遇到ASP.NET repeater控件添加序號列,有些新手可能還不會,網(wǎng)上搜集整理了一些,需要的朋友可以參考下
ASP.NET repeater添加序號列的方法
1、<itemtemplate>
<tr><td>
<%# Container.ItemIndex + 1%>
</td></tr>
</itemtemplate>
2、<itemtemplate>
<tr><td>
<%# this.rpResult.Items.Count + 1%>
</td></tr>
</itemtemplate>
3、在<form></form>中添加<Label ID="dd" ></Label>
<body nload="show()">
<Script. Language="JScript">
function show()
{
var bj = document.all.tags("LABEL");
for (i=0;i<obj.length;i++)
{
document.all["dd"][i].innerHTML=i+1;
}
}
</script>
4、后臺實現(xiàn)方法:
在.aspx里添加<asp:Label id="Label1" Runat="server"></asp:Label>
在.cs里添加
** void InitializeComponent()
{
this.Repeater1.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(this.Repeater1_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load);
}
** void Repeater1_ItemDataBound(object source, System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
((Label)e.Item.FindControl("Label1")).Text = Convert.ToString(e.Item.ItemIndex + 1);
}
}
根據(jù)條件添加html
<%#Container.ItemIndex == 8 ? "<br><a target='_blank'><img style='width:338px;heigh:70px' src='/ImportAD/ADmid.gif'> </a>" : ""%>
ASP.NET repeater添加序號列的方法
1、<itemtemplate>
<tr><td>
<%# Container.ItemIndex + 1%>
</td></tr>
</itemtemplate>
2、<itemtemplate>
<tr><td>
<%# this.rpResult.Items.Count + 1%>
</td></tr>
</itemtemplate>
3、在<form></form>中添加<Label ID="dd" ></Label>
<body nload="show()">
<Script. Language="JScript">
function show()
{
var bj = document.all.tags("LABEL");
for (i=0;i<obj.length;i++)
{
document.all["dd"][i].innerHTML=i+1;
}
}
</script>
4、后臺實現(xiàn)方法:
在.aspx里添加<asp:Label id="Label1" Runat="server"></asp:Label>
在.cs里添加
** void InitializeComponent()
{
this.Repeater1.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(this.Repeater1_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load);
}
** void Repeater1_ItemDataBound(object source, System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
((Label)e.Item.FindControl("Label1")).Text = Convert.ToString(e.Item.ItemIndex + 1);
}
}
根據(jù)條件添加html
<%#Container.ItemIndex == 8 ? "<br><a target='_blank'><img style='width:338px;heigh:70px' src='/ImportAD/ADmid.gif'> </a>" : ""%>
您可能感興趣的文章:
- asp.net Repeater取得CheckBox選中的某行某個值的c#寫法
- asp.net repeater手寫分頁實例代碼
- asp.net Repeater之非常好的數(shù)據(jù)分頁
- asp.net中讓Repeater和GridView支持DataPager分頁
- asp.net Repeater 數(shù)據(jù)綁定的具體實現(xiàn)(圖文詳解)
- asp.net 遍歷repeater中的控件的幾種方式
- asp.net下Repeater使用 AspNetPager分頁控件
- asp.net repeater實現(xiàn)批量刪除
- asp.net Repeater控件的說明及詳細介紹及使用方法
- asp.net Repeater 數(shù)據(jù)綁定代碼
- JQuery實現(xiàn)Repeater無刷新批量刪除(附后臺asp.net源碼)
- 決定何時使用 DataGrid、DataList 或 Repeater(ASP.NET 技術文章)
- ASP.NET筆記之 Repeater的使用
- asp.net DataList與Repeater用法區(qū)別
- 詳解ASP.NET數(shù)據(jù)綁定操作中Repeater控件的用法
相關文章
擁有網(wǎng)頁版小U盤 ASP.NET實現(xiàn)文件上傳與下載功能
這篇文章主要為大家詳細介紹了ASP.NET實現(xiàn)文件上傳與下載功能,類似于U盤功能,具有一定的參考價值。感興趣的小伙伴們可以參考一下2016-08-08asp net core 2.1中如何使用jwt(從原理到精通)
這篇文章主要給大家介紹了關于asp net core 2.1中如何使用jwt(從原理到精通)的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面來一起看看吧2018-11-11ASP.NET連接MySql數(shù)據(jù)庫的2個方法及示例
這篇文章主要介紹了ASP.NET連接MySql數(shù)據(jù)庫的2個方法及示例,使用的是MySQL官方組件和ODBC.NET,需要的朋友可以參考下2014-03-03ASP.NET UserControl 通信的具體實現(xiàn)
下面我就用ASP.NET的UserControl模擬SharePoint UserControl通信,兩者的本質,思想和實現(xiàn)方式都不變。2013-06-06