I am fetching Two Columns from database, one column has data type as varbinary. I am converting the varbinary column to byte[] and then to string. Code is working for console application and keeping the string format. But when i am using the same code in Web Application and displaying the data in GridView, it losing the format. For Ex:
Hello
World
will be displaying as Hello World in Grid View. Here is my code :
SqlConnection con = new SqlConnection("Data Source=.; Initial Catalog=legal; Integrated Security=True");
SqlCommand cmd = new SqlCommand("usp_output_repayment @id=1", con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Columns.Add("Category");
dt.Columns.Add("Description");
while (dr.Read())
{
DataRow dr1 = dt.NewRow();
dr1["Category"] = dr[0];
dr1["Description"] = System.Text.ASCIIEncoding.ASCII.GetString((byte[])dr[1]).Normalize();
dt.Rows.Add(dr1);
}
GridView1.DataSource = dt;
GridView1.DataBind();


DataBind()in Winform