Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ASP.NET C# set GridView Column htmlencode to false from C#

ASP.NET C# set GridView Column htmlencode to false from C#

Scheduled Pinned Locked Moved C#
csharphtmlasp-netsecurityhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    al3xutzu00
    wrote on last edited by
    #1

    Hi Experts, I have an issue with the GridView for wich I want to set a column htmlencode property to false. Here is the data source. I have no databound columns because I'm not using SQLDataSource.

    public void LoadStories()
    {
    SqlConnection con = new SqlConnection("Data Source=dpeta-ro;Initial Catalog=MINTPRINT;Integrated Security=True");
    SqlCommand cmdSelect = new SqlCommand("select news_id \"id\", title \"title\", news_text \"story\", created_date \"created on\", active from news", con);
    SqlDataReader rd;

            try
            {
                con.Open();
                rd = cmdSelect.ExecuteReader();
                gwNews.DataSource = rd;
                gwNews.DataBind();
                con.Close();
            }
            catch (Exception err)
            {
                lblError.Text = err.Message;
                con.Close();
            }
        
        }
    

    The news_text column has HTML code that i want the GridView to render as HTML code, without encoding it. Because the GW has the Encode set to true by default i need to change it dynamically. Any ideas? Thank you, Alex

    “Be the change you want to see in the world.”

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups