Member_2_3703398
asked on
C# String Manipulation
Hi,
I have a GridView that contains a comapny name. The problem is that although the GridView displays the text correct e.g. 'Smtih & Sons', when my code gets the text from the cell, i am returned 'Smith & Sons'.
How can I get it to return what I can see on the screen?
Thanks.
I have a GridView that contains a comapny name. The problem is that although the GridView displays the text correct e.g. 'Smtih & Sons', when my code gets the text from the cell, i am returned 'Smith & Sons'.
How can I get it to return what I can see on the screen?
Thanks.
protected void GridViewBrowseResults_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("ViewFile"))
{
int index = Convert.ToInt32(e.CommandArgument);
string myRootDir = BrowseType;
string myCompanyDir = GridViewBrowseResults.Rows[index].Cells[1].Text;
string mySubDir = myListDirectoryMap[index].File_Folder;
string myFileName = GridViewBrowseResults.Rows[index].Cells[3].Text;
myToolBox.SetAccessPath(myRootDir, myCompanyDir, mySubDir, myFileName);
}
}
Watch Results:
index 0 int
myRootDir "quotation" string
myCompanyDir "Smith & Sons" string
mySubDir "12008" string
myFileName "FQ-0000012008-0" string
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh great, this site's system is even too ghetto to handle itself, lol. The first two lines are supposed to say
< & gt;
> & lt;
No spaces between the letters and the & though
< & gt;
> & lt;
No spaces between the letters and the & though
my post above should handle all of the characters...
Setting BoundField.HtmlEncode to false will do the trick as well.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.htmlencode.aspx
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.htmlencode.aspx
ASKER
Hi,
Thank you all for the posts. Tetorvik, I tried your suggestion but unfortunately, I had no success with it.
Thank you all for the posts. Tetorvik, I tried your suggestion but unfortunately, I had no success with it.
ASKER
Thank you for the code. Works like a dream.
< >
> <
" "
& &
' ' // Not always, though!
That's all I can think of off the top of my head, for now.