Repeater隔行變色,兩個方式

2021-07-04 19:53:15 字數 1590 閱讀 1630

[html]view plain

copy

print?

<

table

>

<

tr>

<

td>

使用者編號

td>

tr>

<

asp:repeaterid=

"rptuser"

runat

="server"

>

<

itemtemplate

>

<

trstyle

='background-color:<%#(container.itemindex%2==0)?"red":"green"%>'

>

<

td>

<

%#eval("uid")%

>

td>

tr>

itemtemplate

>

asp:repeater

>

table

>

在asp.net**中,繫結repeater時,有時候需要隔行進行變色。如奇數行顯示一種顏色,偶數行顯示另一種顏色。效果圖如上圖所示,今天就看看繫結repeater時的一點技巧。

[html]view plain

copy

print?

<

ulid

="list"

>

<

asp:repeaterid=

"rpttest"

runat

="server"

>

<

itemtemplate

>

<

liclass

="odd"

>

<

%#container.itemindex+1 %

>

.<

%#eval("title") %

>

li>

itemtemplate

>

<

alternatingitemtemplate

>

<

liclass

="even"

>

<

%#container.itemindex+1 %

>

.<

%#eval("title") %

>

li>

alternatingitemtemplate

>

asp:repeater

>

ul>

可以看出,間隔換色時用到了。接下來,在樣式中稍微設定下,就可以實現了。如下:

#list

#list

li.odd

.even

最後,繫結行號時用了<%#container.itemindex+1>,itemindex從0開始,所以使用時要加1。

兩個Repeater巢狀使用

在c 中有時存在著兩個巢狀迴圈的存在,此時可以使用兩個repeater進行迴圈獲取到。例如 aspx頁面中 面部護膚熱銷排行榜 很明顯的是,此時在頁面布局中是存在著兩個repeater存在的。aspx.cs頁面中 region 初始化頁面 public void initdata string us...

Repeater中同行兩個值的運算

當前行的jquery處理方式 input type text tag actualcount live keyup function var self this var val self.val var index self.attr index var price span tag systema...

SharePoint 禁用本地回環的兩個方法

有兩種方法中,若要變通解決此問題,請根據您的具體情況使用下列方法之一。設定disablestrictnamechecking 為 1 的登錄檔項。281308 連線到 smb 共享一台基於 windows 2000 的計算機或基於 windows server 2003 的計算機上可能無法使用別名 ...