本文整理汇总了C#中System.Web.UI.WebControls.PlaceHolder.DataBind方法的典型用法代码示例。如果您正苦于以下问题:C# PlaceHolder.DataBind方法的具体用法?C# PlaceHolder.DataBind怎么用?C# PlaceHolder.DataBind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.PlaceHolder
的用法示例。
在下文中一共展示了PlaceHolder.DataBind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderContents
protected override void RenderContents(HtmlTextWriter writer)
{
if (Extender.AdapterEnabled)
{
DataList dataList = Control as DataList;
int columns = (dataList.SeparatorTemplate == null ? RepeatColumns : RepeatColumns * 2);
if (dataList != null)
{
if (dataList.RepeatLayout == RepeatLayout.Table)
{
writer.Indent++;
writer.WriteLine();
writer.WriteBeginTag("table");
writer.WriteAttribute("cellpadding", dataList.CellPadding.ToString());
writer.WriteAttribute("cellspacing", dataList.CellSpacing.ToString());
writer.WriteAttribute("summary", Control.ToolTip);
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
if (dataList.HeaderTemplate != null && dataList.ShowHeader)
{
if (!String.IsNullOrEmpty(dataList.Caption))
{
writer.WriteLine();
writer.WriteBeginTag("caption");
writer.Write(HtmlTextWriter.TagRightChar);
writer.Write(dataList.Caption);
writer.WriteEndTag("caption");
}
writer.WriteLine();
writer.WriteBeginTag("thead");
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
writer.WriteBeginTag("tr");
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
writer.WriteBeginTag("th");
writer.WriteAttribute("colspan", columns.ToString());
string className = "AspNet-DataList-Header ";
if (dataList.HeaderStyle != null)
{
className += dataList.HeaderStyle.CssClass;
}
writer.WriteAttribute("class", className);
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
PlaceHolder container = new PlaceHolder();
dataList.HeaderTemplate.InstantiateIn(container);
container.DataBind();
container.RenderControl(writer);
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("th");
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("tr");
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("thead");
}
if (dataList.FooterTemplate != null && dataList.ShowFooter)
{
writer.WriteLine();
writer.WriteBeginTag("tfoot");
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
writer.WriteBeginTag("tr");
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
writer.WriteBeginTag("td");
writer.WriteAttribute("colspan", columns.ToString());
string className = "AspNet-DataList-Footer ";
if (dataList.FooterStyle != null)
{
className += dataList.FooterStyle.CssClass;
}
writer.WriteAttribute("class", className);
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
PlaceHolder container = new PlaceHolder();
dataList.FooterTemplate.InstantiateIn(container);
container.DataBind();
container.RenderControl(writer);
//.........这里部分代码省略.........
示例2: RenderContents
protected override void RenderContents(HtmlTextWriter writer)
{
if (Extender.AdapterEnabled)
{
DataList dataList = Control as DataList;
if (dataList != null)
{
writer.Indent++;
writer.WriteLine();
writer.WriteBeginTag("table");
writer.WriteAttribute("cellpadding", "0");
writer.WriteAttribute("cellspacing", "0");
writer.WriteAttribute("summary", Control.ToolTip);
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
if (dataList.HeaderTemplate != null)
{
PlaceHolder container = new PlaceHolder();
dataList.HeaderTemplate.InstantiateIn(container);
container.DataBind();
if ((container.Controls.Count == 1) && typeof(LiteralControl).IsInstanceOfType(container.Controls[0]))
{
writer.WriteLine();
writer.WriteBeginTag("caption");
writer.Write(HtmlTextWriter.TagRightChar);
LiteralControl literalControl = container.Controls[0] as LiteralControl;
writer.Write(literalControl.Text.Trim());
writer.WriteEndTag("caption");
}
else
{
writer.WriteLine();
writer.WriteBeginTag("thead");
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
writer.WriteBeginTag("tr");
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
writer.WriteBeginTag("th");
writer.WriteAttribute("colspan", RepeatColumns.ToString());
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
container.RenderControl(writer);
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("th");
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("tr");
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("thead");
}
}
if (dataList.FooterTemplate != null)
{
writer.WriteLine();
writer.WriteBeginTag("tfoot");
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
writer.WriteBeginTag("tr");
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
writer.WriteBeginTag("td");
writer.WriteAttribute("colspan", RepeatColumns.ToString());
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
PlaceHolder container = new PlaceHolder();
dataList.FooterTemplate.InstantiateIn(container);
container.DataBind();
container.RenderControl(writer);
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("td");
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("tr");
writer.Indent--;
//.........这里部分代码省略.........