|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Griview cells Text Special Characterssuch 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 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. Show quote 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 & 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 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. Show quote "Phil H" <goo***@philphall.me.uk> wrote in message news:1192182950.931366.169890@q3g2000prf.googlegroups.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 & 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 > > 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/library/system.web.ui.webcontrols.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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. -------------------- >From: "john" <n***@none.com> <1192182950.931366.169***@q3g2000prf.googlegroups.com>>References: <u#8dYOLDIHA.3***@TK2MSFTNGP04.phx.gbl> Show quote >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" <goo***@philphall.me.uk> wrote in message >news:1192182950.931366.169890@q3g2000prf.googlegroups.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 & 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 >> >> > > > 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. Show quote "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message news:s4ne5htDIHA.4664@TK2MSFTNGHUB02.phx.gbl... > 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/library/system.web.ui.webcontrols.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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx. > > ================================================== > > > This posting is provided "AS IS" with no warranties, and confers no > rights. > > > > > > -------------------- >>From: "john" <n***@none.com> >>References: <u#8dYOLDIHA.3***@TK2MSFTNGP04.phx.gbl> > <1192182950.931366.169***@q3g2000prf.googlegroups.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" <goo***@philphall.me.uk> wrote in message >>news:1192182950.931366.169890@q3g2000prf.googlegroups.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 & 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 >>> >>> >> >> >> > 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" <n***@none.com> <1192182950.931366.169***@q3g2000prf.googlegroups.com> >References: <u#8dYOLDIHA.3***@TK2MSFTNGP04.phx.gbl> <O0c6ugeDIHA.***@TK2MSFTNGP05.phx.gbl> <s4ne5htDIHA.4***@TK2MSFTNGHUB02.phx.gbl> Show quote >Subject: Re: Griview cells Text Special Characters http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfiel>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]" <stch***@online.microsoft.com> wrote in message >news:s4ne5htDIHA.4664@TK2MSFTNGHUB02.phx.gbl... >> 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 >> Show quote >> d.htmlencode.aspx http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif>> >> 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 >> Show quote >> 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/subscriptions/support/default.aspx. >> >> ================================================== >> >> >> This posting is provided "AS IS" with no warranties, and confers no >> rights. >> >> >> >> >> >> -------------------- >>>From: "john" <n***@none.com> >>>References: <u#8dYOLDIHA.3***@TK2MSFTNGP04.phx.gbl> >> <1192182950.931366.169***@q3g2000prf.googlegroups.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" <goo***@philphall.me.uk> wrote in message >>>news:1192182950.931366.169890@q3g2000prf.googlegroups.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 & 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 >>>> >>>> >>> >>> >>> >> > > > On 12 , 12:38, "john" <n***@none.com> wrote: Try this:> 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 ven = Server.HtmlDecode(me.Gridview1.SelectedRow.Cells(2).Text) Regards, Mykola http://marss.co.ua |
|||||||||||||||||||||||