亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Verzeichnis suchen
ASP.NET 基礎(chǔ)教程 ASP.NET 教程 Web Pages - 教程 Web Pages - 添加 Razor 代碼 Web Pages - 頁(yè)面布局 Web Pages - 文件夾 Web Pages - 全局頁(yè)面 Web Pages - HTML 表單 Web Pages - 對(duì)象 Web Pages - 文件 Web Pages - 幫助器 Web Pages - WebGrid 幫助器 Web Pages - Chart 幫助器 Web Pages - WebMail 幫助器 Web Pages - PHP Web Pages - 發(fā)布網(wǎng)站 Razor - 標(biāo)記 Web Pages - Database 對(duì)象 ASP.NET MVC Web Forms - 教程 Web Forms - HTML 頁(yè)面 Web Forms - 服務(wù)器控件 Web Forms - 事件 Web Forms - HTML 表單 Web Forms - 維持 ViewState Web Forms - TextBox 控件 Web Forms - Button 控件 Web Forms - 數(shù)據(jù)綁定 Web Forms - ArrayList 對(duì)象 Web Forms - Hashtable 對(duì)象 Web Forms - SortedList 對(duì)象 Web Forms - XML 文件 Web Forms - Repeater 控件 Web Forms - DataList 控件 Web Forms - 數(shù)據(jù)庫(kù)連接 Web Forms - 母版頁(yè) Web Forms - 導(dǎo)航 ASP.NET Razor Razor - C# 和 VB 代碼語(yǔ)法 Razor - C# 變量 Razor - C# 循環(huán)和數(shù)組 Razor - C# 邏輯條件 Razor - VB 變量 Razor - VB 循環(huán)和數(shù)組 Razor - VB 邏輯條件 WF 參考手冊(cè) Web Forms - HTML 服務(wù)器控件 ASP.NET HtmlAnchor 控件 ASP.NET HtmlButton 控件 ASP.NET HtmlForm 控件 ASP.NET HtmlGeneric 控件 ASP.NET HtmlImage 控件 ASP.NET HtmlInputButton 控件 ASP.NET HtmlInputCheckBox 控件 ASP.NET HtmlInputFile 控件 ASP.NET HtmlInputHidden 控件 ASP.NET HtmlInputImage 控件 ASP.NET HtmlInputRadioButton 控件 ASP.NET HtmlInputText 控件 ASP.NET HtmlSelect Control ASP.NET HtmlTable 控件 ASP.NET HtmlTableCell 控件 ASP.NET HtmlTableRow 控件 ASP.NET HtmlTextArea 控件 ASP.NET AdRotator 控件 ASP.NET AdRotator AdvertisementFile 屬性 ASP.NET AdRotator Target 屬性 ASP.NET Button 控件 ASP.NET Button CausesValidation 屬性 ASP.NET Button OnClientClick 屬性 ASP.NET Button PostBackUrl 屬性 ASP.NET Button Text 屬性 ASP.NET Button UseSubmitBehavior 屬性 ASP.NET Button ValidationGroup 屬性 ASP.NET Calendar 控件 ASP.NET Calendar Caption 屬性 ASP.NET Calendar CaptionAlign 屬性 ASP.NET Calendar CellPadding 屬性 ASP.NET Calendar CellSpacing 屬性 ASP.NET Calendar DayHeaderStyle 屬性 ASP.NET Style 控件 ASP.NET BackColor 屬性 ASP.NET BorderColor 屬性 ASP.NET BorderStyle 屬性 ASP.NET BorderWidth 屬性 ASP.NET CssClass 屬性 ASP.NET Font 屬性 ASP.NET ForeColor 屬性 ASP.NET Height 屬性 ASP.NET Width 屬性 ASP.NET Calendar DayNameFormat 屬性 ASP.NET Calendar DayStyle 屬性 ASP.NET Calendar FirstDayOfWeek 屬性 ASP.NET Calendar NextMonthText 屬性 ASP.NET Calendar NextPrevFormat 屬性 ASP.NET Calendar NextPrevStyle 屬性 ASP.NET Calendar OtherMonthDayStyle 屬性 ASP.NET Calendar PrevMonthText 屬性 ASP.NET Calendar SelectedDate 屬性 ASP.NET Calendar SelectedDates 屬性 ASP.NET Calendar SelectedDayStyle 屬性 ASP.NET Calendar SelectionMode 屬性 ASP.NET Calendar SelectMonthText 屬性 ASP.NET Calendar SelectorStyle 屬性 ASP.NET Calendar SelectWeekText 屬性 ASP.NET Calendar ShowDayHeader 屬性 ASP.NET Calendar ShowGridLines 屬性 ASP.NET Calendar ShowNextPrevMonth 屬性 ASP.NET Calendar ShowTitle 屬性 ASP.NET Calendar TitleFormat 屬性 ASP.NET Calendar TitleStyle 屬性 ASP.NET Calendar TodayDayStyle 屬性 ASP.NET Calendar TodaysDate 屬性 ASP.NET Calendar VisibleDate 屬性 ASP.NET Calendar WeekendDayStyle 屬性 ASP.NET CalendarDay 控件 ASP.NET CalendarDay Date 屬性 ASP.NET CalendarDay DayNumberText 屬性 ASP.NET CalendarDay IsOtherMonth 屬性 ASP.NET CalendarDay IsSelectable 屬性 ASP.NET CalendarDay IsSelected 屬性 ASP.NET CalendarDay IsToday 屬性 ASP.NET CalendarDay IsWeekend 屬性 ASP.NET CheckBox 控件 ASP.NET CheckBox Checked 屬性 ASP.NET CheckBox Text 屬性 ASP.NET CheckBox TextAlign 屬性 ASP.NET CheckBoxList 控件 ASP.NET CheckBoxList CellPadding 屬性 ASP.NET CheckBoxList CellSpacing 屬性 ASP.NET CheckBoxList RepeatColumns 屬性 ASP.NET CheckBoxList RepeatDirection 屬性 ASP.NET CheckBoxList RepeatLayout 屬性 ASP.NET CheckBoxList TextAlign 屬性 ASP.NET DropDownList 控件 ASP.NET DropDownList SelectedIndex 屬性 ASP.NET HyperLink 控件 ASP.NET HyperLink ImageUrl 屬性 ASP.NET HyperLink NavigateUrl 屬性 ASP.NET HyperLink Target 屬性 ASP.NET HyperLink Text 屬性 ASP.NET Image 控件 ASP.NET Image AlternateText 屬性 ASP.NET Image ImageAlign 屬性 ASP.NET Image ImageUrl 屬性 ASP.NET ImageButton 控件 ASP.NET ImageButton CausesValidation 屬性 ASP.NET ImageButton ValidationGroup 屬性 ASP.NET ImageButton PostBackUrl 屬性 ASP.NET ImageButton ValidationGroup 屬性 ASP.NET Label 控件 ASP.NET LinkButton 控件 ASP.NET LinkButton OnClientClick 屬性 ASP.NET LinkButton PostBackUrl 屬性 ASP.NET LinkButton Text 屬性 ASP.NET LinkButton ValidationGroup 屬性 ASP.NET ListBox 控件 ASP.NET Rows 屬性 ASP.NET SelectionMode 屬性 ASP.NET ListItem 控件 ASP.NET ListItem Enabled 屬性 ASP.NET ListItem Selected 屬性 ASP.NET ListItem Text 屬性 ASP.NET ListItem Value 屬性 ASP.NET Literal 控件 ASP.NET Literal Text 屬性 ASP.NET Panel 控件 ASP.NET Panel BackImageUrl 屬性 ASP.NET Panel DefaultButton 屬性 ASP.NET Panel Direction 屬性 ASP.NET Panel GroupingText 屬性 ASP.NET Panel HorizontalAlign 屬性 ASP.NET Panel ScrollBars 屬性 ASP.NET Panel Wrap 屬性 ASP.NET PlaceHolder 控件 ASP.NET RadioButton 控件 ASP.NET RadioButtonList 控件 ASP.NET RadioButtonList CellPadding 屬性 ASP.NET RadioButtonList CellSpacing 屬性 ASP.NET RadioButtonList RepeatColumns 屬性 ASP.NET RadioButtonList RepeatDirection 屬性 ASP.NET RadioButtonList TextAlign 屬性 ASP.NET BulletedList BulletImageUrl 屬性 Web Forms - Web 服務(wù)器控件 ASP.NET Table 控件 ASP.NET BackImageUrl 屬性 ASP.NET Caption 屬性 ASP.NET CaptionAlign 屬性 ASP.NET CellPadding 屬性 ASP.NET CellSpacing 屬性 ASP.NET GridLines 屬性 ASP.NET HorizontalAlign 屬性 ASP.NET TableCell 控件 ASP.NET TableCell ColumnSpan 屬性 ASP.NET TableCell HorizontalAlign 屬性 ASP.NET TableCell RowSpan 屬性 ASP.NET TableCell Text 屬性 ASP.NET TableCell Wrap 屬性 ASP.NET TableRow 控件 ASP.NET TableRow HorizontalAlign 屬性 ASP.NET TableRow TableSection 屬性 ASP.NET TableRow VerticalAlign 屬性 ASP.NET TextBox 控件 ASP.NET TextBox AutoCompleteType 屬性 ASP.NET TextBox AutoPostBack 屬性 ASP.NET TextBox Columns 屬性 ASP.NET TextBox MaxLength 屬性 ASP.NET TextBox ReadOnly 屬性 ASP.NET TextBox Rows 屬性 ASP.NET TextBox Text 屬性 ASP.NET TextBox TextMode 屬性 ASP.NET TextBox Wrap 屬性 ASP.NET XML 控件 ASP.NET XML DocumentSource 屬性 Web Forms - Validation 服務(wù)器控件 ASP.NET CompareValidator 控件 ASP.NET CustomValidator 控件 ASP.NET RangeValidator 控件 ASP.NET RegularExpressionValidator 控件 ASP.NET RequiredFieldValidator 控件 ASP.NET ValidationSummary 控件 ASP.NET BulletedList 控件 ASP.NET BulletedList BulletStyle 屬性 ASP.NET BulletedList DisplayMode 屬性 ASP.NET BulletedList FirstBulletNumber 屬性 ASP.NET BulletedList Target 屬性 WP 參考手冊(cè) Web Pages - 類(lèi) Web Pages - WebSecurity 對(duì)象 WebSecurity 屬性 - CurrentUserId WebSecurity 屬性 -?CurrentUserName WebSecurity 屬性 - HasUserId WebSecurity 屬性 - IsAuthenticated WebSecurity - ChangePassword() WebSecurity - ConfirmAccount() WebSecurity - CreateAccount() WebSecurity - CreateUserAndAccount() WebSecurity - GeneratePasswordResetToken() WebSecurity - GetCreateDate() WebSecurity - GetPasswordChangeDate() WebSecurity - GetUserId() WebSecurity - InitializeDatabaseConnection() WebSecurity - IsConfirmed() WebSecurity - IsCurrentUser() WebSecurity - Login() WebSecurity - Logout() WebSecurity - RequireAuthenticatedUser() WebSecurity - RequireRoles() WebSecurity - RequireUser() WebSecurity - ResetPassword() WebSecurity - UserExists() Web Pages - WebMail 對(duì)象 Web Pages - 更多幫助器
Figuren

Web Forms - Repeater 控件



Repeater 控件用于顯示被綁定在該控件上的項(xiàng)目的重復(fù)列表。


綁定 DataSet 到 Repeater 控件

Repeater 控件用于顯示被綁定在該控件上的項(xiàng)目的重復(fù)列表。Repeater 控件可被綁定到數(shù)據(jù)庫(kù)表、XML 文件或者其他項(xiàng)目列表。在這里,我們將演示如何綁定 XML 文件到 Repeater 控件。

在我們的實(shí)例中,我們將使用下面的 XML 文件("cdcatalog.xml"):

<?xml version="1.0" encoding="ISO-8859-1"?>

<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
<cd>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<country>USA</country>
<company>RCA</company>
<price>9.90</price>
<year>1982</year>
</cd>
<cd>
<title>Still got the blues</title>
<artist>Gary Moore</artist>
<country>UK</country>
<company>Virgin records</company>
<price>10.20</price>
<year>1990</year>
</cd>
<cd>
<title>Eros</title>
<artist>Eros Ramazzotti</artist>
<country>EU</country>
<company>BMG</company>
<price>9.90</price>
<year>1997</year>
</cd>
</catalog>

首先,導(dǎo)入 "System.Data" 命名空間。我們需要該命名空間與 DataSet 對(duì)象一起工作。 把下面這條指令包含在 .aspx 頁(yè)面的頂部:

<%@?Import?Namespace="System.Data"?%>

接著,為 XML 文件創(chuàng)建一個(gè) DataSet,并在頁(yè)面第一次加載時(shí)把這個(gè) XML 文件載入 DataSet:

<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
dim mycdcatalog=New DataSet
mycdcatalog.ReadXml(MapPath("cdcatalog.xml"))
end if
end sub

然后我們?cè)?.aspx 頁(yè)面中創(chuàng)建一個(gè) Repeater 控件。<HeaderTemplate> 元素中的內(nèi)容被首先呈現(xiàn),并且在輸出中僅出現(xiàn)一次,而 <ItemTemplate> 元素中的內(nèi)容會(huì)對(duì)應(yīng) DataSet 中的每條 "record" 重復(fù)出現(xiàn),最后,<FooterTemplate> 元素中的內(nèi)容在輸出中僅出現(xiàn)一次:

<html>
<body>

<form runat="server">
<asp:Repeater id="cdcatalog" runat="server">

<HeaderTemplate>
...
</HeaderTemplate>

<ItemTemplate>
...
</ItemTemplate>

<FooterTemplate>
...
</FooterTemplate>

</asp:Repeater>
</form>

</body>
</html>

然后我們添加創(chuàng)建 DataSet 的腳本,并且綁定 mycdcatalog DataSet 到 Repeater 控件。然后 使用 HTML 標(biāo)簽來(lái)填充 Repeater 控件,并通過(guò) <%#Container.DataItem("fieldname")%> 綁定數(shù)據(jù)項(xiàng)目到 <ItemTemplate> 區(qū)域內(nèi)的單元格中:

實(shí)例

<%@ Import Namespace="System.Data" %>

<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
dim mycdcatalog=New DataSet
mycdcatalog.ReadXml(MapPath("cdcatalog.xml"))
cdcatalog.DataSource=mycdcatalog
cdcatalog.DataBind()
end if
end sub
</script>

<html>
<body>

<form runat="server">
<asp:Repeater id="cdcatalog" runat="server">

<HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>Title</th>
<th>Artist</th>
<th>Country</th>
<th>Company</th>
<th>Price</th>
<th>Year</th>
</tr>
</HeaderTemplate>

<ItemTemplate>
<tr>
<td><%#Container.DataItem("title")%></td>
<td><%#Container.DataItem("artist")%></td>
<td><%#Container.DataItem("country")%></td>
<td><%#Container.DataItem("company")%></td>
<td><%#Container.DataItem("price")%></td>
<td><%#Container.DataItem("year")%></td>
</tr>
</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>

</asp:Repeater>
</form>

</body>
</html>

使用 <AlternatingItemTemplate>

您可以在 <ItemTemplate> 元素后添加 <AlternatingItemTemplate> 元素,用來(lái)描述輸出中交替行的外觀。在下面的實(shí)例中,表格每隔一行就會(huì)顯示為淺灰色的背景:

實(shí)例

<%@ Import Namespace="System.Data" %>

<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
dim mycdcatalog=New DataSet
mycdcatalog.ReadXml(MapPath("cdcatalog.xml"))
cdcatalog.DataSource=mycdcatalog
cdcatalog.DataBind()
end if
end sub
</script>

<html>
<body>

<form runat="server">
<asp:Repeater id="cdcatalog" runat="server">

<HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>Title</th>
<th>Artist</th>
<th>Country</th>
<th>Company</th>
<th>Price</th>
<th>Year</th>
</tr>
</HeaderTemplate>

<ItemTemplate>
<tr>
<td><%#Container.DataItem("title")%></td>
<td><%#Container.DataItem("artist")%></td>
<td><%#Container.DataItem("country")%></td>
<td><%#Container.DataItem("company")%></td>
<td><%#Container.DataItem("price")%></td>
<td><%#Container.DataItem("year")%></td>
</tr>
</ItemTemplate>

<AlternatingItemTemplate>
<tr bgcolor="#e8e8e8">
<td><%#Container.DataItem("title")%></td>
<td><%#Container.DataItem("artist")%></td>
<td><%#Container.DataItem("country")%></td>
<td><%#Container.DataItem("company")%></td>
<td><%#Container.DataItem("price")%></td>
<td><%#Container.DataItem("year")%></td>
</tr>
</AlternatingItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>

</asp:Repeater>
</form>

</body>
</html>

使用 <SeparatorTemplate>

<SeparatorTemplate> 元素用于描述每個(gè)記錄之間的分隔符。在下面的實(shí)例中,每個(gè)表格行之間插入了一條水平線:

實(shí)例

<%@ Import Namespace="System.Data" %>

<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
dim mycdcatalog=New DataSet
mycdcatalog.ReadXml(MapPath("cdcatalog.xml"))
cdcatalog.DataSource=mycdcatalog
cdcatalog.DataBind()
end if
end sub
</script>

<html>
<body>

<form runat="server">
<asp:Repeater id="cdcatalog" runat="server">

<HeaderTemplate>
<table border="0" width="100%">
<tr>
<th>Title</th>
<th>Artist</th>
<th>Country</th>
<th>Company</th>
<th>Price</th>
<th>Year</th>
</tr>
</HeaderTemplate>

<ItemTemplate>
<tr>
<td><%#Container.DataItem("title")%></td>
<td><%#Container.DataItem("artist")%></td>
<td><%#Container.DataItem("country")%></td>
<td><%#Container.DataItem("company")%></td>
<td><%#Container.DataItem("price")%></td>
<td><%#Container.DataItem("year")%></td>
</tr>
</ItemTemplate>

<SeparatorTemplate>
<tr>
<td colspan="6"><hr /></td>
</tr>
</SeparatorTemplate>

<FooterTemplate>
</table>
</FooterTemplate>

</asp:Repeater>
</form>

</body>
</html>

Vorheriger Artikel: N?chster Artikel: