0

I have this code in C#/ASP.net

foreach (String projectType in ProjectsByProjectType.Keys)
{
    HtmlTableRow trh = new HtmlTableRow();
    HtmlTableCell tdProjectType = new HtmlTableCell();
    tdProjectType.InnerHtml = projectType;
    trh.Controls.Add(tdProjectType);
    tableLocal.Controls.Add(trh);
}

When this line runs

tdProjectType.InnerHtml = projectType; 

I'd like the text within the innerHTML to be in a bold font type (so take the string referenced by 'projectType' and make it bold). How do I do this?

iabbott
  • 873
  • 1
  • 8
  • 23
Mufasatheking
  • 387
  • 2
  • 6
  • 16

4 Answers4

3

Use a <b> tag:

 tdProjectType.InnerHtml = "<b>" + projectType + "</b>";
Darren
  • 68,902
  • 24
  • 138
  • 144
3

You can try

foreach (String projectType in ProjectsByProjectType.Keys)
{
    HtmlTableRow trh = new HtmlTableRow();
    HtmlTableCell tdProjectType = new HtmlTableCell();
    tdProjectType.InnerHtml = "<b>"+projectType+"</b>";
    trh.Controls.Add(tdProjectType);
    tableLocal.Controls.Add(trh);
}
iabbott
  • 873
  • 1
  • 8
  • 23
Pawan
  • 1,065
  • 5
  • 10
1

I think the semantically correct way would be to use one of the following in preferential order

tdProjectType.InnerHtml = "<h2>" + projectType "</h2>";

or whichever h tag you want to use

tdProjectType.InnerHtml = "<strong>" + projectType "</strong>"; tdProjectType.InnerHtml = "<b>" + projectType "</b>";

Nicholas King
  • 938
  • 7
  • 22
0

This is quite simple you just need to write the string in bold tags like:

<b> String</b>
Incredible
  • 3,495
  • 8
  • 49
  • 77