0

Hi,

I'm using a dataTable to bind my gridView and during the data binding I need to make some cells bold. The structure I'm looking for is this:

Person
contact
Person 2
contact

To include the spaces when binding the table I'm using Server.HtmlDecode("&nbsp;&nbsp;&nbsp;"). I tried Server.HtmlDecode("<b>") ... Server.HtmlDecode("</b>") to make the text bold, but it didn't work.

Any suggestions?

Thanks,

Ana

5
Contributors
5
Replies
10
Views
8 Years
Discussion Span
Last Post by Sals
0

Put them in a <div> or <span> and set the class or in line style?

<div style="font-weight: bold"> text </div>

and use the same method to get the indent

<div style="text-indent:10px"> text </div>

or use padding.

0

Put them in a <div> or <span> and set the class or in line style?

<div style="font-weight: bold"> text </div>

and use the same method to get the indent

<div style="text-indent:10px"> text </div>

or use padding.

This will not working in my case, because of the way I'm binding my gridView. First I'm binding it with all the "person" names and then I'm iterating through the "person" names and including the contacts associated. So, in the ASP.NET gridView I have:

<asp:Label ID="PersonOrContactName" runat="server" Text='<%#Eval("Name") %>' />

This means the list of person or contact names is one single column in my DataTable, and this columns is called "Name". The thing is: I want the cell bold only when it's a person name; when it's a contact name, it should be regular.

Is it possible to do?

0

You can try like this.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[2].Font.Bold = true;    
        }

    }
0

The best way to edit the gridview is to write the code in its RowDataBound event

Example :

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        for (int j = 0; j < e.Row.Cells.Count; j++)
        {

            e.Row.Cells[j].Style.Add("BORDER-BOTTOM", "#aaccee 1px solid");

            e.Row.Cells[j].Style.Add("BORDER-RIGHT", "#aaccee 1px solid");
            e.Row.Cells[j].Style.Add("padding-left", "5px");

        }
    }

I Hope this will help you

Regards,
Karan Salekar

Hi,

I'm using a dataTable to bind my gridView and during the data binding I need to make some cells bold. The structure I'm looking for is this:

Person
contact
Person 2
contact

To include the spaces when binding the table I'm using Server.HtmlDecode("&nbsp;&nbsp;&nbsp;"). I tried Server.HtmlDecode("<b>") ... Server.HtmlDecode("</b>") to make the text bold, but it didn't work.

Any suggestions?

Thanks,

Ana

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.