<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Data Presentation Controls</title><link>http://forums.asp.net/24.aspx</link><description>ASP.NET data-bound controls such as the DataGrid, DataList, GridView, FormView, DetailsView, and Repeater Controls.  &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=23&amp;c=17" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Replacing \n line breaks with HTML br line breaks in Gridview; what is the recommended practice.</title><link>http://forums.asp.net/thread/3296927.aspx</link><pubDate>Thu, 16 Jul 2009 09:52:12 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3296927</guid><dc:creator>crossbyname</dc:creator><author>crossbyname</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3296927.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=3296927</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Hi, this alternative may be useful for any VB user formating in a DetailsView:&lt;/p&gt;&lt;pre class="vb.net" name="code"&gt;&amp;lt;asp:TemplateField HeaderText=&amp;quot;Description&amp;quot;&amp;gt;
                &amp;lt;ItemTemplate&amp;gt;
                 &amp;lt;%#Replace(Container.DataItem(&amp;quot;Description&amp;quot;), vbCrLf, &amp;quot;&amp;lt;br&amp;gt;&amp;quot;)%&amp;gt;
                &amp;lt;/ItemTemplate&amp;gt;
                &amp;lt;/asp:TemplateField&amp;gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Thank you Aaron for the starter, helped me work this out.&lt;/p&gt;
&lt;p&gt;Tim&lt;/p&gt;</description></item><item><title>Re: Replacing \n line breaks with HTML br line breaks in Gridview; what is the recommended practice.</title><link>http://forums.asp.net/thread/2514989.aspx</link><pubDate>Fri, 25 Jul 2008 15:33:19 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2514989</guid><dc:creator>emrahustun</dc:creator><author>emrahustun</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2514989.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=2514989</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Thank you so much Contributor.&lt;/p&gt;&lt;p&gt;&amp;nbsp;That works.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Replacing \n line breaks with HTML br line breaks in Gridview; what is the recommended practice.</title><link>http://forums.asp.net/thread/2513184.aspx</link><pubDate>Fri, 25 Jul 2008 00:46:57 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2513184</guid><dc:creator>agolden</dc:creator><author>agolden</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2513184.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=2513184</wfw:commentRss><description>&lt;p&gt;Hi emrahustun,&lt;/p&gt;
&lt;p&gt;A way to work around this is to declare your formatting method to accept an object, then check for DBNull and format appropriately.&amp;nbsp; So, you&amp;#39;d have:&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="dir"&gt;&amp;lt;%#&lt;/span&gt; Eval(&amp;quot;about&amp;quot;) &lt;span class="dir"&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;and the formatting method would be something like:&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;protected string&lt;/span&gt; FormatString(&lt;span class="kwd"&gt;object&lt;/span&gt; o)
{
    &lt;span class="kwd"&gt;if&lt;/span&gt; (o.Equals(DBNull.Value))
    {
        &lt;span class="kwd"&gt;return&lt;/span&gt; String.Empty;
    }
    &lt;span class="kwd"&gt;else&lt;/span&gt;
    {
        &lt;span class="kwd"&gt;return&lt;/span&gt; ((&lt;span class="kwd"&gt;string&lt;/span&gt;)o).Replace(&lt;span class="st"&gt;&amp;quot;\n&amp;quot;&lt;/span&gt;, &lt;span class="st"&gt;&amp;quot;&amp;amp;lt;br/&amp;amp;gt;&amp;quot;&lt;/span&gt;);
    }
}&lt;/pre&gt;
&lt;p&gt;Hope that helps.&lt;/p&gt;
&lt;p&gt;Aaron&lt;/p&gt;</description></item><item><title>Re: Replacing \n line breaks with HTML br line breaks in Gridview; what is the recommended practice.</title><link>http://forums.asp.net/thread/2513071.aspx</link><pubDate>Thu, 24 Jul 2008 22:03:52 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2513071</guid><dc:creator>emrahustun</dc:creator><author>emrahustun</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2513071.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=2513071</wfw:commentRss><description>&lt;p&gt;thank you very much.&lt;br /&gt;actually, i tried it before.&lt;br /&gt;if &amp;quot;about&amp;quot; is empty, i thing eval is giving this error. (with or without an if-null function)&lt;/p&gt;&lt;p&gt;so this didn&amp;#39;t work too: satirdonusum((string)Eval(&amp;quot;about&amp;quot;))&lt;br /&gt;&lt;br /&gt;Error is:&lt;br /&gt;&lt;b&gt;Unable to cast object of type &amp;#39;System.DBNull&amp;#39; to type &amp;#39;System.String&amp;#39;.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;i can&amp;#39;t fix this. can you help?&lt;/p&gt;</description></item><item><title>Re: Replacing \n line breaks with HTML br line breaks in Gridview; what is the recommended practice.</title><link>http://forums.asp.net/thread/2512899.aspx</link><pubDate>Thu, 24 Jul 2008 20:42:55 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2512899</guid><dc:creator>conankingofcool</dc:creator><author>conankingofcool</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2512899.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=2512899</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;You can make your own Server-Side function that takes a string as the parameter and does the replace only if the string isn&amp;#39;t null and then returns it. Then you can do this.&lt;/p&gt;
&lt;p&gt;&amp;lt;&lt;span class="tag"&gt;asp:Label&lt;/span&gt;&lt;span class="attr"&gt; ID=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;Label2&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; runat=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; Text=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;#39;&lt;span class="dir"&gt;&amp;lt;%#&lt;/span&gt; YourFunction(Eval(&amp;quot;about&amp;quot;)) &lt;span class="dir"&gt;%&amp;gt;&lt;/span&gt;&amp;#39;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span class="tag"&gt;asp:Label&lt;/span&gt;&amp;gt;&lt;/p&gt;</description></item><item><title>Re: Replacing \n line breaks with HTML br line breaks in Gridview; what is the recommended practice.</title><link>http://forums.asp.net/thread/2512692.aspx</link><pubDate>Thu, 24 Jul 2008 19:16:28 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2512692</guid><dc:creator>emrahustun</dc:creator><author>emrahustun</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2512692.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=2512692</wfw:commentRss><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;i&amp;#39;m beginner for asp.net.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;now i have a problem with this.&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;b&gt;&amp;lt;&lt;span class="tag"&gt;asp:Label&lt;/span&gt;&lt;span class="attr"&gt; ID=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;Label2&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; runat=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; Text=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;#39;&lt;span class="dir"&gt;&amp;lt;%#&lt;/span&gt; ((string)Eval(&amp;quot;about&amp;quot;)).Replace(&amp;quot;\n&amp;quot;, &amp;quot;&amp;lt;br/&amp;gt;&amp;quot;)  &lt;span class="dir"&gt;%&amp;gt;&lt;/span&gt;&amp;#39;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span class="tag"&gt;asp:Label&lt;/span&gt;&amp;gt;&lt;/b&gt;&lt;/pre&gt;&lt;pre class="coloredcode"&gt;if about is empty, it&amp;#39;s giving an error. how can i use &lt;b&gt;if(&lt;span class="attrv"&gt;Eval(&amp;quot;about&amp;quot;))!=null)&lt;/span&gt;&lt;/b&gt;&lt;span class="attrv"&gt; whit this?&lt;/span&gt;&lt;/pre&gt;&lt;pre class="coloredcode"&gt;Thanks. &lt;br /&gt;&lt;/pre&gt;</description></item><item><title>Re: Replacing \n line breaks with HTML br line breaks in Gridview; what is the recommended practice.</title><link>http://forums.asp.net/thread/2509725.aspx</link><pubDate>Wed, 23 Jul 2008 19:15:49 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2509725</guid><dc:creator>emrahustun</dc:creator><author>emrahustun</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2509725.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=2509725</wfw:commentRss><description>&lt;p&gt;After 6 years,&lt;/p&gt;&lt;p&gt;thank you for solution. i was searching everywhere... &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Replacing \n line breaks with HTML br line breaks in Gridview; what is the recommended practice.</title><link>http://forums.asp.net/thread/1808862.aspx</link><pubDate>Tue, 17 Jul 2007 22:09:23 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1808862</guid><dc:creator>butterpecan</dc:creator><author>butterpecan</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1808862.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1808862</wfw:commentRss><description>&lt;p&gt;oh my god, you guys are awesome!!&lt;/p&gt;
&lt;p&gt;I have tried this problem for two days, but&amp;nbsp;I couldn&amp;#39;t figure it out.&lt;/p&gt;
&lt;p&gt;Finally, I got it!!&lt;/p&gt;
&lt;p&gt;Thank you Aaron&lt;/p&gt;</description></item><item><title>Re: Replacing \n line breaks with HTML br line breaks in Gridview; what is the recommended practice.</title><link>http://forums.asp.net/thread/1472441.aspx</link><pubDate>Tue, 21 Nov 2006 15:17:17 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1472441</guid><dc:creator>Sojan80</dc:creator><author>Sojan80</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1472441.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1472441</wfw:commentRss><description>agolden this solution just rocks! YOu are indeed a sanity saver!&lt;br /&gt;</description></item><item><title>Re: Replacing \n line breaks with HTML br line breaks in Gridview; what is the recommended practice.</title><link>http://forums.asp.net/thread/1404974.aspx</link><pubDate>Wed, 20 Sep 2006 14:00:50 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1404974</guid><dc:creator>tod1d</dc:creator><author>tod1d</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1404974.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1404974</wfw:commentRss><description>&lt;p&gt;Hi Aaron,&lt;/p&gt;&lt;p&gt;Your solution is more aesthtic than mine and it works just as well.&lt;/p&gt;&lt;p&gt;Thank you for the input.&lt;/p&gt;</description></item><item><title>Re: Replacing \n line breaks with HTML br line breaks in Gridview; what is the recommended practice.</title><link>http://forums.asp.net/thread/1404498.aspx</link><pubDate>Wed, 20 Sep 2006 03:46:36 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1404498</guid><dc:creator>agolden</dc:creator><author>agolden</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1404498.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1404498</wfw:commentRss><description>&lt;p&gt;Todd,&lt;/p&gt;&lt;p&gt;I typically put that type of formatting in the GridView markup, either explicitly if the field is never null, or calling a method to handle the null values and make the replacement.&lt;/p&gt;&lt;pre class="coloredcode"&gt;&amp;lt;&lt;span class="tag"&gt;ItemTemplate&lt;/span&gt;&amp;gt;
	&lt;span class="dir"&gt;&amp;lt;%#&lt;/span&gt; ((string)Eval(&amp;quot;Details&amp;quot;)).Replace(&amp;quot;\n&amp;quot;, &amp;quot;&amp;lt;br/&amp;gt;&amp;quot;) &lt;span class="dir"&gt;%&amp;gt;&lt;/span&gt;
&amp;lt;/&lt;span class="tag"&gt;ItemTemplate&lt;/span&gt;&amp;gt;

&amp;lt;&lt;span class="tag"&gt;ItemTemplate&lt;/span&gt;&amp;gt;
	&lt;span class="dir"&gt;&amp;lt;%#&lt;/span&gt; FormatString(Eval(&amp;quot;Details&amp;quot;)) &lt;span class="dir"&gt;%&amp;gt;&lt;/span&gt;
&amp;lt;/&lt;span class="tag"&gt;ItemTemplate&lt;/span&gt;&amp;gt;
&lt;/pre&gt;&lt;p&gt;Aaron&amp;nbsp;&lt;/p&gt;</description></item><item><title>Replacing \n line breaks with HTML br line breaks in Gridview; what is the recommended practice.</title><link>http://forums.asp.net/thread/1403884.aspx</link><pubDate>Tue, 19 Sep 2006 15:45:11 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1403884</guid><dc:creator>tod1d</dc:creator><author>tod1d</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1403884.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1403884</wfw:commentRss><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;It has been awhile since I have manipulated data in a Gridview. I am binding an collection to a Gridview and one of the values contains non-html line breaks (\n). I would like to convert these to html line breaks (&amp;lt;br /&amp;gt;). The code below works fine.&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;protected void&lt;/span&gt; gridHistory_RowDataBound(&lt;span class="kwd"&gt;object&lt;/span&gt; sender, GridViewRowEventArgs e)
{
	GridViewRow row = e.Row;
	&lt;span class="kwd"&gt;if&lt;/span&gt; (e.Row.RowType == DataControlRowType.DataRow)
	{
		row.Cells[0].Text = row.Cells[0].Text.Replace(&lt;span class="st"&gt;&amp;quot;\n&amp;quot;&lt;/span&gt;, &lt;span class="st"&gt;&amp;quot;&amp;lt;br /&amp;gt;&amp;quot;&lt;/span&gt;);
	}
}&lt;/pre&gt;&lt;p&gt;&lt;font size="2"&gt;Is there an &amp;quot;easier&amp;quot;/&amp;quot;better&amp;quot; way of doing it?&lt;/font&gt;&lt;/p&gt;&lt;p&gt;Thanks.&lt;/p&gt;</description></item></channel></rss>