当前位置: 首页>>代码示例>>C#>>正文


C# PlaceHolder.DataBind方法代码示例

本文整理汇总了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);
//.........这里部分代码省略.........
开发者ID:skt90u,项目名称:skt90u-framework-dotnet,代码行数:101,代码来源:DataListAdapter.cs

示例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--;
//.........这里部分代码省略.........
开发者ID:brandongrossutti,项目名称:DotCopter,代码行数:101,代码来源:DataListAdapter.cs


注:本文中的System.Web.UI.WebControls.PlaceHolder.DataBind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。