【问题标题】:Add a label to a DataGrid's TemplateField itemtemplate. But not the front end将标签添加到 DataGrid 的 TemplateField itemtemplate。但不是前端
【发布时间】:2010-11-26 09:58:08
【问题描述】:

C#、.net

原代码:

 <asp:TemplateField ItemStyle-Width="20px" ItemStyle-HorizontalAlign="Center">
 <itemtemplate>
 <asp:Label ID="lblDependency" Runat="server"></asp:Label>
 </itemtemplate>
 </asp:TemplateField>

我想做这样的事情:

 BoundField bf = new BoundField();
 bf.DataField = "b";
 grvList.Columns.Add(bf);

但不是boundfield,而是使用templatefield。

如果你想知道我为什么要做这样的事情,它与:this

【问题讨论】:

    标签: c# .net gridview templatefield


    【解决方案1】:

    http://msdn.microsoft.com/en-us/library/Aa289501 涵盖了我相信的内容(向下滚动到底部查看 DataGrid 完整示例)。基本上你不能让它直接解析 ASP 标签,你必须创建一个以编程方式实现它们的自定义类,然后实例化该类。

    【讨论】:

      猜你喜欢
      • 2015-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-12
      • 2010-10-29
      • 2013-07-06
      • 1970-01-01
      • 2012-01-15
      相关资源
      最近更新 更多