Using aspnet 3.5, c# - Is there a way to insert Html into a gridview row?
Yes. Use the TemplateField
, and then type your html directly into the markup. If the html is suppose to be dynamically created I would use a Literal
instead of a Label
.
<asp:GridView id="GridView1" runat="server">
<Columns>
<asp:TemplateField headertext="Column1">
<ItemTemplate>
<br />
<h1>
<%# Eval ("DataColumnName") %>
</h1>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField headertext="Column2">
<ItemTemplate>
<asp:Literal id="Literal1" runat="server" text='<%# Eval ("DataColumnName2") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Simply modify the Text
property of a cell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With