In my website I am preparing an array using datagrid items in c#, which works fine, however when I have some text in the grid which has "
as value code automatically replaces it with "
i have tried to replace "
with "
as below, however its failing and replacing "
with \"
Array.Value += "|" + dgrFinal.Rows[i].Cells[1].Text.Replace
("amp;", "").Replace(""","\"")
is there any way i can replace "
with ".
Can anyone please help me in this.....come on guys you are expert.
You can use HttpUtility
. Here is an example.
using System.Web;
...
string value1 = "<html>";
string value2 = HttpUtility.HtmlDecode(value1);
string value3 = HttpUtility.HtmlEncode(value2);
Debug.WriteLine(value1);
Debug.WriteLine(value2);
Debug.WriteLine(value3);
This is the ouput:
<html>
<html>
<html>
I took the example from here.
Have you tried
.Replace(""", @"""")
Edit: outside of a GridView (I'm using LinqPad)
string xxx = "sd"fd";
Console.WriteLine(xxx.Replace(""", @""""));
returns:
sd"fd
If it's still appearing as \" then the battle is with the gridView - I haven't used one for ages but I'd be tempted to try and get the data right before binding to the grid, rather than looping through the rows and cells afterwards.
Edit2: I was going to say it could be the the debugger escaping the quotes but I'm days behind on this one. Good spot @Rawling. At least it's now solved :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With