Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Griview cells Text Special Characters

Reply
Thread Tools

Griview cells Text Special Characters

 
 
john
Guest
Posts: n/a
 
      10-12-2007
When I get a Gridview Cell contents that has a Special Character in its data
such as an & or " it returns it constant & or " instead of the
actual Character.



Any way to modify this code to get the actual Character as it is displayed
in the cell?



Sample cell actual text: A & C Hauling



dim ven as String

ven = me.Gridview1.SelectedRow.Cells(2).Text



Result to ven variable is A & Hauling



Thanks

John


 
Reply With Quote
 
 
 
 
Phil H
Guest
Posts: n/a
 
      10-12-2007
John

I take it that the code is in response to the "selected-index_changed"
event (Y/N?)

If so then you need to retrieve the data from the original data source
rather than the content of grid cells. The easiest way is to obtain
the record's primary key value and query the source programatically.

On 12 Oct, 10:38, "john" <n...@none.com> wrote:
> When I get a Gridview Cell contents that has a Special Character in its data
> such as an & or " it returns it constant &amp; or &quot; instead of the
> actual Character.
>
> Any way to modify this code to get the actual Character as it is displayed
> in the cell?
>
> Sample cell actual text: A & C Hauling
>
> dim ven as String
>
> ven = me.Gridview1.SelectedRow.Cells(2).Text
>
> Result to ven variable is A &amp; Hauling
>
> Thanks
>
> John



 
Reply With Quote
 
 
 
 
john
Guest
Posts: n/a
 
      10-13-2007
Actually I am pulling the cell contents into a formview from the already
selected record, but I think considering the few special Characters I would
to just do replace on the cell data than have to pull from the datasource
all over again.

I was hoping there was a simple way to convert or cast it from its constant.

Thanks for your reply.

"Phil H" <> wrote in message
news: ups.com...
> John
>
> I take it that the code is in response to the "selected-index_changed"
> event (Y/N?)
>
> If so then you need to retrieve the data from the original data source
> rather than the content of grid cells. The easiest way is to obtain
> the record's primary key value and query the source programatically.
>
> On 12 Oct, 10:38, "john" <n...@none.com> wrote:
>> When I get a Gridview Cell contents that has a Special Character in its
>> data
>> such as an & or " it returns it constant &amp; or &quot; instead of the
>> actual Character.
>>
>> Any way to modify this code to get the actual Character as it is
>> displayed
>> in the cell?
>>
>> Sample cell actual text: A & C Hauling
>>
>> dim ven as String
>>
>> ven = me.Gridview1.SelectedRow.Cells(2).Text
>>
>> Result to ven variable is A &amp; Hauling
>>
>> Thanks
>>
>> John

>
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      10-15-2007
Hi John,

For the character formatting, are you using the default "BoundField"? If
so, gridview's boundfield will perform html encoding on boundfield
content(when set via databinding) so as to avoid some potential malicious
injected script code:

#BoundField.HtmlEncode Property
http://msdn2.microsoft.com/en-us/lib...rols.boundfiel
d.htmlencode.aspx

You can try turn it off if you're sure the characters in the content is
safe and non characters in it will bread page's html source(e.g it doesn't
contain chars like '<', '>'....).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.





--------------------
>From: "john" <>
>References: <u#>

<. com>
>Subject: Re: Griview cells Text Special Characters
>Date: Sat, 13 Oct 2007 18:27:01 -0400
>
>Actually I am pulling the cell contents into a formview from the already
>selected record, but I think considering the few special Characters I

would
>to just do replace on the cell data than have to pull from the datasource
>all over again.
>
>I was hoping there was a simple way to convert or cast it from its

constant.
>
>Thanks for your reply.
>
>"Phil H" <> wrote in message
>news: oups.com...
>> John
>>
>> I take it that the code is in response to the "selected-index_changed"
>> event (Y/N?)
>>
>> If so then you need to retrieve the data from the original data source
>> rather than the content of grid cells. The easiest way is to obtain
>> the record's primary key value and query the source programatically.
>>
>> On 12 Oct, 10:38, "john" <n...@none.com> wrote:
>>> When I get a Gridview Cell contents that has a Special Character in its
>>> data
>>> such as an & or " it returns it constant &amp; or &quot; instead of the
>>> actual Character.
>>>
>>> Any way to modify this code to get the actual Character as it is
>>> displayed
>>> in the cell?
>>>
>>> Sample cell actual text: A & C Hauling
>>>
>>> dim ven as String
>>>
>>> ven = me.Gridview1.SelectedRow.Cells(2).Text
>>>
>>> Result to ven variable is A &amp; Hauling
>>>
>>> Thanks
>>>
>>> John

>>
>>

>
>
>


 
Reply With Quote
 
marss
Guest
Posts: n/a
 
      10-16-2007
On 12 , 12:38, "john" <n...@none.com> wrote:

> Any way to modify this code to get the actual Character as it is displayed
> in the cell?
>
> Sample cell actual text: A & C Hauling
>
> dim ven as String
>
> ven = me.Gridview1.SelectedRow.Cells(2).Text
>
> Result to ven variable is A &amp; Hauling


Try this:

ven = Server.HtmlDecode(me.Gridview1.SelectedRow.Cells(2 ).Text)

Regards,
Mykola
http://marss.co.ua


 
Reply With Quote
 
john
Guest
Posts: n/a
 
      10-16-2007
Thanks for all your input, I tried setting HtmlEncode to False and that
worked. Seeing as I do not allow any editing of that cell, I take it that it
will be safe to do.

But I also want to try the latest Idea of: Server.HtmlDecode to see how that
works also for the times when I need that security.

Thanks for all your help.

"Steven Cheng[MSFT]" <> wrote in message
news:...
> Hi John,
>
> For the character formatting, are you using the default "BoundField"? If
> so, gridview's boundfield will perform html encoding on boundfield
> content(when set via databinding) so as to avoid some potential malicious
> injected script code:
>
> #BoundField.HtmlEncode Property
> http://msdn2.microsoft.com/en-us/lib...rols.boundfiel
> d.htmlencode.aspx
>
> You can try turn it off if you're sure the characters in the content is
> safe and non characters in it will bread page's html source(e.g it doesn't
> contain chars like '<', '>'....).
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications.
>
>
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscripti...t/default.aspx.
>
> ==================================================
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
>
>
>
> --------------------
>>From: "john" <>
>>References: <u#>

> <. com>
>>Subject: Re: Griview cells Text Special Characters
>>Date: Sat, 13 Oct 2007 18:27:01 -0400
>>
>>Actually I am pulling the cell contents into a formview from the already
>>selected record, but I think considering the few special Characters I

> would
>>to just do replace on the cell data than have to pull from the datasource
>>all over again.
>>
>>I was hoping there was a simple way to convert or cast it from its

> constant.
>>
>>Thanks for your reply.
>>
>>"Phil H" <> wrote in message
>>news: roups.com...
>>> John
>>>
>>> I take it that the code is in response to the "selected-index_changed"
>>> event (Y/N?)
>>>
>>> If so then you need to retrieve the data from the original data source
>>> rather than the content of grid cells. The easiest way is to obtain
>>> the record's primary key value and query the source programatically.
>>>
>>> On 12 Oct, 10:38, "john" <n...@none.com> wrote:
>>>> When I get a Gridview Cell contents that has a Special Character in its
>>>> data
>>>> such as an & or " it returns it constant &amp; or &quot; instead of the
>>>> actual Character.
>>>>
>>>> Any way to modify this code to get the actual Character as it is
>>>> displayed
>>>> in the cell?
>>>>
>>>> Sample cell actual text: A & C Hauling
>>>>
>>>> dim ven as String
>>>>
>>>> ven = me.Gridview1.SelectedRow.Cells(2).Text
>>>>
>>>> Result to ven variable is A &amp; Hauling
>>>>
>>>> Thanks
>>>>
>>>> John
>>>
>>>

>>
>>
>>

>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      10-17-2007
You're welcome

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "john" <>
>References: <u#>

<. com>
<>
<>
>Subject: Re: Griview cells Text Special Characters
>Date: Tue, 16 Oct 2007 18:20:37 -0400


>Thanks for all your input, I tried setting HtmlEncode to False and that
>worked. Seeing as I do not allow any editing of that cell, I take it that

it
>will be safe to do.
>
>But I also want to try the latest Idea of: Server.HtmlDecode to see how

that
>works also for the times when I need that security.
>
>Thanks for all your help.
>
>"Steven Cheng[MSFT]" <> wrote in message
>news:...
>> Hi John,
>>
>> For the character formatting, are you using the default "BoundField"? If
>> so, gridview's boundfield will perform html encoding on boundfield
>> content(when set via databinding) so as to avoid some potential malicious
>> injected script code:
>>
>> #BoundField.HtmlEncode Property
>>

http://msdn2.microsoft.com/en-us/lib...rols.boundfiel
>> d.htmlencode.aspx
>>
>> You can try turn it off if you're sure the characters in the content is
>> safe and non characters in it will bread page's html source(e.g it

doesn't
>> contain chars like '<', '>'....).
>>
>> Sincerely,
>>
>> Steven Cheng
>>
>> Microsoft MSDN Online Support Lead
>>
>>
>>
>> ==================================================
>>
>> Get notification to my posts through email? Please refer to
>>

http://msdn.microsoft.com/subscripti...ult.aspx#notif
>> ications.
>>
>>
>>
>> Note: The MSDN Managed Newsgroup support offering is for non-urgent

issues
>> where an initial response from the community or a Microsoft Support
>> Engineer within 1 business day is acceptable. Please note that each

follow
>> up response may take approximately 2 business days as the support
>> professional working with you may need further investigation to reach the
>> most efficient resolution. The offering is not appropriate for situations
>> that require urgent, real-time or phone-based interactions or complex
>> project analysis and dump analysis issues. Issues of this nature are best
>> handled working with a dedicated Microsoft Support Engineer by contacting
>> Microsoft Customer Support Services (CSS) at
>> http://msdn.microsoft.com/subscripti...t/default.aspx.
>>
>> ==================================================
>>
>>
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>
>>
>>
>>
>> --------------------
>>>From: "john" <>
>>>References: <u#>

>> <. com>
>>>Subject: Re: Griview cells Text Special Characters
>>>Date: Sat, 13 Oct 2007 18:27:01 -0400
>>>
>>>Actually I am pulling the cell contents into a formview from the already
>>>selected record, but I think considering the few special Characters I

>> would
>>>to just do replace on the cell data than have to pull from the datasource
>>>all over again.
>>>
>>>I was hoping there was a simple way to convert or cast it from its

>> constant.
>>>
>>>Thanks for your reply.
>>>
>>>"Phil H" <> wrote in message
>>>news: groups.com...
>>>> John
>>>>
>>>> I take it that the code is in response to the "selected-index_changed"
>>>> event (Y/N?)
>>>>
>>>> If so then you need to retrieve the data from the original data source
>>>> rather than the content of grid cells. The easiest way is to obtain
>>>> the record's primary key value and query the source programatically.
>>>>
>>>> On 12 Oct, 10:38, "john" <n...@none.com> wrote:
>>>>> When I get a Gridview Cell contents that has a Special Character in

its
>>>>> data
>>>>> such as an & or " it returns it constant &amp; or &quot; instead of

the
>>>>> actual Character.
>>>>>
>>>>> Any way to modify this code to get the actual Character as it is
>>>>> displayed
>>>>> in the cell?
>>>>>
>>>>> Sample cell actual text: A & C Hauling
>>>>>
>>>>> dim ven as String
>>>>>
>>>>> ven = me.Gridview1.SelectedRow.Cells(2).Text
>>>>>
>>>>> Result to ven variable is A &amp; Hauling
>>>>>
>>>>> Thanks
>>>>>
>>>>> John
>>>>
>>>>
>>>
>>>
>>>

>>

>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can not change Headertext with sorting ability in Griview from code behind Charly ASP .Net 1 02-20-2010 04:46 AM
Re: Meta-Characters, Special Characters xah@xahlee.org Java 2 05-31-2007 09:25 AM
convert yyyymmdd text cells into date cells =?Utf-8?B?ZF9jYW1wZWxvQGhvdG1haWwuY29t?= Microsoft Certification 2 11-22-2006 04:52 PM
How to convert HTML special characters to the real characters with a Java script Stefan Mueller HTML 3 07-23-2006 10:09 PM
Cells[].Text or Cells[].Controls[0] Joel Finkel ASP .Net Datagrid Control 0 09-01-2003 04:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57