【问题标题】:ASP.NET non-html escaped string to GridViewASP.NET 非 html 转义字符串到 GridView
【发布时间】:2012-03-06 23:51:34
【问题描述】:

我有 GridView 和我的 DAO 作为数据源呈现一些人数据(姓名,姓氏...)。我想添加到渲染表的简单链接,以扩展视图并提供更多信息。我以为我可以为每一行添加带有 POST 参数的 html 链接。但是我尝试传递给 GridView 的每个 html 都会被转义。我能以某种方式摆脱它吗?或者有没有其他简单的方法?

这是我私人的、非常快速的项目,我不需要任何强大的解决方案。只是最简单和最快的一种。谢谢。

【问题讨论】:

    标签: c# asp.net html gridview


    【解决方案1】:

    听起来您想在网格视图中使用 ItemTemplate 在网格中呈现 HTML 控件:

                asp:GridView ID="myGrid" runat="server">
                    <Columns>
                        <asp:TemplateField HeaderText="Last Name">
                            <ItemTemplate>
                                <!--Any HTML can go here, below is a label -->
                                <label><%# DataBinder.Eval (Container.DataItem, "lastname") %><label>                        
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                 </asp:GridView>
    

    【讨论】:

      猜你喜欢
      • 2012-05-27
      • 2012-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-06
      • 1970-01-01
      相关资源
      最近更新 更多