當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。