I'd like to make some words of a cell in gridview Bold. For example - "MRN No.: SI0021848
Name: Cherry" like my attachment. I could query this field value from database but don't know how to make some words Bold. How to do it?
I notice that you want to show two different information into one cell, which means you want to bind two fields into one cell. You should convert the column into TemplateField, just like this:
soclose
Member
13 Points
59 Posts
how to make some words of a cell in gridview bold type
Aug 16, 2010 03:55 PM|LINK
Hi All,
I'd like to make some words of a cell in gridview Bold. For example - "MRN No.: SI0021848 Name: Cherry" like my attachment. I could query this field value from database but don't know how to make some words Bold. How to do it?
Regards,
soclose
<input id="gwProxy" type="hidden"><input onclick="jsCall();" id="jsProxy" type="hidden">
<div id="refHTML"></div><input id="gwProxy" type="hidden"><input onclick="jsCall();" id="jsProxy" type="hidden">
<div id="refHTML"></div>GridVeiw
sansan
All-Star
53942 Points
8147 Posts
Re: how to make some words of a cell in gridview bold type
Aug 16, 2010 05:16 PM|LINK
Set HtmlEncode as false for the bound field and you can insert html into the column text
<b>MRN No:</b>SI0021848 <b>Name:</b> Cherry
I'm not sure how your data is, but you can get this from your query or you can do this string manipulation in code behind.
try that and see if it works
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: how to make some words of a cell in gridview bold type
Aug 19, 2010 01:38 AM|LINK
I notice that you want to show two different information into one cell, which means you want to bind two fields into one cell. You should convert the column into TemplateField, just like this:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Mother Details">
<ItemTemplate>
<%#AutoFormat1(Eval("Field1")) %> <%#AutoFormat2(Eval("Field2")) %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
And then write two formation codes:
public partial class WebForm1 : System.Web.UI.Page
{
protected string AutoFormat1(object obj)
{
return "<b>MRN No.:</b>" + obj.ToString();
}
protected string AutoFormat2(object obj)
{
return "<b>Name:</b>" + obj.ToString();
}
protected void Page_Load(object sender, EventArgs e)
{
}