Special Character does not displays in gridview
I have asp.net grid view which binds data from xml file but in the grid i am unable to see the special character which is present in the xml file. The actual value e.g. 4-Â-0444 got modified to 4-Â0444 due to html encoding. Is there any way to stop this encoding process globally in the website.
Asp.net Code
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="BillNo" HeaderText="BillNo" />
<asp:BoundField DataField="PageNo" HeaderText="PageNo" />
<asp:BoundField DataField="Activity" HeaderText="Activity" HtmlEncode="false" />
</Columns>
</asp:GridView>
C# Code
DataSet dsResult = new DataSet();
dsResult.ReadXml(new StreamReader(Server.MapPath("XMLFile1.xml")));
if (dsResult.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = dsResult.Tables[0];
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[2].Text = Server.HtmlEncode(Convert.ToString(e.Row.Cells[2].Text));
}
}
XML
<Tenders>
<Ravina>
<BillNo>1</BillNo>
<PageNo>10</PageNo>
<Activity>Metals</Activity>
</Ravina>
<Ravina>
<BillNo>2</BillNo>
<PageNo>20</PageNo>
<Activity>Formworks</Activity>
</Ravina>
<Ravina>
<BillNo>3</BillNo>
<PageNo>30</PageNo>
<Activity>4-Â-0444</Activity>
</Ravina>
</Tenders>
Final Output
BillNo PageNo Activity
1 10 Metals
2 20 Formworks
3 30 4-Â0444 (This value got modified, actual value <Activity>4-Â-0444</Activity> )
Thanks