asp.netboldfont-style

ASP.NET - First 2 chars in string must be bold


I have a table with rows where i have a number in every row. I want this number of rows must be with font-style: bold

This is my code :

DataTable table = new DataTable();
table.Columns.Add("Route");

int counter = 1;
foreach (SPListItem item in myItemColForTable)
{
    DataRow row = table.NewRow();
    row["Route"] = counter.ToString() + ". " + item["Route"].ToString();
    counter ++;
}

DataView mydataview = new DataView(table);
table = mydataview.ToTable(true, "Route");
myGrid.DataSource = table;
myGrid.DataBind();

I want this string -->

counter.ToString() + ". "

must be with bold style.


Solution

  • Well you could pull out the text and replace it with a span with the bold option turned on.

    Example :

    void Item_Bound(Object sender, DataGridItemEventArgs e)
    {
        string yourSubString = "some string to bold";
        e.Item.Cells[0].Text = e.Item.Cells[0].Text.Replace(yourSubString,
            string.Format("<span style='font-weight: bold'>{0}</span>", yourSubString));
    
    }