locked
Add New DataTable row with HTML/CSS in C# RRS feed

  • Question

  • User447264667 posted

    Here's the code I'm trying, which populates a gridview

    DataRow row = gvLegend.NewRow();
    row[0] = "<b>Department:</b> " + gdepartmentName ;
    row[1] = imgLegend.ImageUrl = "~/Images/green.png";
    gvLegend.Rows.Add(row);
    gvLegend.AcceptChanges();

    row[0] shows as:
    <b>Department:</b> CARDIOLOGY (2020))

    I've tried the Encode and Decode methods - it never shows the HTML like it should. I know I've done this before ---- What am I missing?

    Friday, December 21, 2018 2:38 PM

Answers

  • User447264667 posted

    Found the answer - this was in code behind.

    What you also need to do is to set the BoundField htmlencode property to false

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 21, 2018 4:56 PM