DataList.SeparatorTemplate Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Denetimin öğeleri DataList arasındaki ayırıcının şablonunu alır veya ayarlar.
public:
virtual property System::Web::UI::ITemplate ^ SeparatorTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.DataListItem))]
public virtual System.Web.UI.ITemplate SeparatorTemplate { get; set; }
[<System.ComponentModel.Browsable(false)>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.DataListItem))>]
member this.SeparatorTemplate : System.Web.UI.ITemplate with get, set
Public Overridable Property SeparatorTemplate As ITemplate
Özellik Değeri
ITemplate Denetimdeki öğeler DataList arasındaki ayırıcının şablonunu içeren bir. null
varsayılan değerdir.
- Öznitelikler
Örnekler
Aşağıdaki kod örneği, denetimindeki SeparatorTemplate her öğe DataList arasındaki ayırıcının içeriğini denetlemek için özelliğinin nasıl kullanılacağını gösterir.
Not
Aşağıdaki kod örneği tek dosyalı kod modelini kullanır ve doğrudan arka planda kod dosyasına kopyalandığında düzgün çalışmayabilir. Bu kod örneği.aspx uzantısına sahip boş bir metin dosyasına kopyalanmalıdır. Web Forms kod modeli hakkında daha fazla bilgi için bkz. ASP.NET Web Forms Sayfa Kodu Modeli.
<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<script runat="server">
ICollection CreateDataSource()
{
// Create sample data for the DataList control.
DataTable dt = new DataTable();
DataRow dr;
// Define the columns of the table.
dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue", typeof(String)));
dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));
dt.Columns.Add(new DataColumn("ImageValue", typeof(String)));
// Populate the table with sample values.
for (int i = 0; i < 9; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Description for item " + i.ToString();
dr[2] = 1.23 * (i + 1);
dr[3] = "Image" + i.ToString() + ".jpg";
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
}
void Page_Load(Object sender, EventArgs e)
{
// Load sample data only once, when the page is first loaded.
if (!IsPostBack)
{
ItemsList.DataSource = CreateDataSource();
ItemsList.DataBind();
}
}
void Selection_Change(Object sender, EventArgs e)
{
// Set the background color for the separator section of
// the DataList control.
ItemsList.SeparatorStyle.BackColor =
System.Drawing.Color.FromName(ItemList.SelectedItem.Value);
}
</script>
<head runat="server">
<title>DataList SeparatorTemplate and SeparatorStyle Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>DataList SeparatorTemplate and SeparatorStyle Example</h3>
Select a background color for the separator between
items in the DataList.
<br /><br />
<asp:DataList id="ItemsList"
BorderColor="black"
CellPadding="5"
CellSpacing="5"
RepeatDirection="Vertical"
RepeatLayout="Table"
RepeatColumns="3"
ShowFooter="True"
runat="server">
<HeaderStyle BackColor="#aaaadd">
</HeaderStyle>
<ItemStyle BackColor="Silver">
</ItemStyle>
<AlternatingItemStyle BackColor="DarkGray">
</AlternatingItemStyle>
<SeparatorStyle BackColor="White">
</SeparatorStyle>
<HeaderTemplate>
List of items
</HeaderTemplate>
<ItemTemplate>
Description: <br />
<%# DataBinder.Eval(Container.DataItem, "StringValue") %>
<br />
Price: <%# DataBinder.Eval(Container.DataItem, "CurrencyValue", "{0:c}") %>
<br />
<asp:Image id="ProductImage"
AlternatingText='<%# DataBinder.Eval(Container.DataItem, "StringValue") %>'
ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ImageValue") %>'
runat="server"/>
</ItemTemplate>
<SeparatorTemplate>
<asp:Image id="SeparatorImage"
GenerateEmptyAlternateText='true'
ImageUrl="SeparatorImage.jpg"
runat="server"/>
</SeparatorTemplate>
</asp:DataList>
<hr />
<table cellpadding="5">
<tr>
<td>
Separator BackColor:
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="ItemList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem Selected="True" Value="White"> White </asp:ListItem>
<asp:ListItem Value="Silver"> Silver </asp:ListItem>
<asp:ListItem Value="DarkGray"> Dark Gray </asp:ListItem>
<asp:ListItem Value="Khaki"> Khaki </asp:ListItem>
<asp:ListItem Value="DarkKhaki"> Dark Khaki </asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<script runat="server">
Function CreateDataSource() As ICollection
' Create sample data for the DataList control.
Dim dt As DataTable = New DataTable()
dim dr As DataRow
' Define the columns of the table.
dt.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn("CurrencyValue", GetType(Double)))
dt.Columns.Add(New DataColumn("ImageValue", GetType(String)))
' Populate the table with sample values.
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Description for item " & i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = "Image" & i.ToString() & ".jpg"
dt.Rows.Add(dr)
Next i
Dim dv As DataView = New DataView(dt)
Return dv
End Function
Sub Page_Load(sender As Object, e As EventArgs)
' Load sample data only once when, the page is first loaded.
If Not IsPostBack Then
ItemsList.DataSource = CreateDataSource()
ItemsList.DataBind()
End If
End Sub
Sub Selection_Change(sender As Object, e As EventArgs)
' Set the background color for the separator section of
' the DataList control.
ItemsList.SeparatorStyle.BackColor = _
System.Drawing.Color.FromName(ItemList.SelectedItem.Value)
End Sub
</script>
<head runat="server">
<title>DataList SeparatorTemplate and SeparatorStyle Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>DataList SeparatorTemplate and SeparatorStyle Example</h3>
Select a background color for the separator between
items in the DataList.
<br /><br />
<asp:DataList id="ItemsList"
BorderColor="black"
CellPadding="5"
CellSpacing="5"
RepeatDirection="Vertical"
RepeatLayout="Table"
RepeatColumns="3"
ShowFooter="True"
runat="server">
<HeaderStyle BackColor="#aaaadd">
</HeaderStyle>
<ItemStyle BackColor="Silver">
</ItemStyle>
<AlternatingItemStyle BackColor="DarkGray">
</AlternatingItemStyle>
<SeparatorStyle BackColor="White">
</SeparatorStyle>
<HeaderTemplate>
List of items
</HeaderTemplate>
<ItemTemplate>
Description: <br />
<%# DataBinder.Eval(Container.DataItem, "StringValue") %>
<br />
Price: <%# DataBinder.Eval(Container.DataItem, "CurrencyValue", "{0:c}") %>
<br />
<asp:Image id="ProductImage"
AlternatingText='<%# DataBinder.Eval(Container.DataItem, "StringValue") %>'
ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ImageValue") %>'
runat="server"/>
</ItemTemplate>
<SeparatorTemplate>
<asp:Image id="SeparatorImage"
GenerateEmptyAlternateText='true'
ImageUrl="SeparatorImage.jpg"
runat="server"/>
</SeparatorTemplate>
</asp:DataList>
<hr />
<table cellpadding="5">
<tr>
<td>
Separator BackColor:
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="ItemList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem Selected="True" Value="White"> White </asp:ListItem>
<asp:ListItem Value="Silver"> Silver </asp:ListItem>
<asp:ListItem Value="DarkGray"> Dark Gray </asp:ListItem>
<asp:ListItem Value="Khaki"> Khaki </asp:ListItem>
<asp:ListItem Value="DarkKhaki"> Dark Khaki </asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</form>
</body>
</html>
Açıklamalar
Denetimin SeparatorTemplate öğeleri DataList arasındaki ayırıcının içeriğini denetlemek için özelliğini kullanın. Ayırıcı, denetimdeki her öğenin arasına özel içerik içeren bir öğe DataList yerleştirmenize olanak tanır. Denetimin öğeleri arasındaki ayırıcının DataList görünümü özelliği tarafından SeparatorStyle denetlenmektedir.
Ayırıcı için bir şablon belirtmek için, etiketleri denetimin <SeparatorTemplate>
açma ve kapatma etiketleri arasına DataList yerleştirin. Ardından, şablonun içeriğini açma ve kapatma <SeparatorTemplate>
etiketleri arasında listeleyebilirsiniz.
Dikkat
Bu denetim, kötü amaçlı istemci betiği içerebilecek kullanıcı girişini görüntülemek için kullanılabilir. Uygulamanızda görüntülemeden önce istemciden yürütülebilir betik, SQL deyimleri veya başka kodlar için gönderilen tüm bilgileri denetleyin. Denetimde giriş metnini görüntülemeden önce kullanıcı girişini doğrulamak için doğrulama denetimlerini kullanabilirsiniz. ASP.NET, kullanıcı girişinde betiği ve HTML'yi engellemek için bir giriş isteği doğrulama özelliği sağlar. Daha fazla bilgi için bkz . Standart Denetimlerin Güvenliğini Sağlama, Nasıl yapılır: Dizelere HTML Kodlaması Uygulayarak Web Uygulamasında Betik Açıklarına Karşı Koruma ve ASP.NET Web Sayfalarında Kullanıcı Girişini Doğrulama.
Şunlara uygulanır
Ayrıca bkz.
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin