<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Using TemplateFields in the GridView Control</title><link>http://www.asp.net</link><pubDate>Fri, 18 May 2012 04:54:42 GMT</pubDate><generator>umbraco</generator><description>Comments for Using TemplateFields in the GridView Control</description><language>en</language><atom:link href="http://www.asp.net/rss/comments/33236" rel="self" type="application/rss+xml" /><item><title>Comment Posted by dvdgzzrll</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Sat, 10 Jul 2010 17:47:49 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-000000009404</guid><description><![CDATA[ <p>what if i have a databound textbox and i want to add text to the box?  how do i do that? i&#39;m sure you can see my problem ... dvdgzzrll@msn.com</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/dvdgzzrll.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by brownre</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Sat, 24 Jul 2010 10:33:14 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-000000009595</guid><description><![CDATA[ <p>Spurious chars in at the end of the URL&#39;s. Plse accept apologies.</p><p>I have one of your tutorials  titled “Using TemplateFields in the GridView Control” with all 4 features working fine with all valid HireDate Values. If a HireDate is deleted or not available the program fails.</p><p>To run the Application with valid dates, I have made a URL  available on the Internet , that works fine <a rel="nofollow" href="http://rayheadly.com/aspnetdev/gridview_control/gridviewtemplatefield.aspx" target="_blank">rayheadly.com/</a>  I have placed a second URL  <a rel="nofollow" href="http://rayheadly.com/aspnetdev/gridview_update/default.aspx" target="_blank">rayheadly.com/</a>  to modify individual records. </p><p>When I removed the HireDate from any record an error occurs. If I ran this program again and tried to re-enter a corrected DateTime it also is rejected.</p><p>The two URL’s  both the On-Line and Client are identical. The programs work correctly on the Client.</p><p>I would welcome a solution to this problem. It is a routine, I am particularly anxious to understand the use of CodeBehind when a record or field is not available. </p><p>Rgds Ray</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/brownre.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by brownre</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Sat, 24 Jul 2010 10:35:09 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-000000009596</guid><description><![CDATA[ <p>Please remove the spurious character from the end of the URL&#39;s</p><p>Rgds Ray</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/brownre.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by BillLH</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Sat, 31 Jul 2010 02:52:00 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-000000009694</guid><description><![CDATA[ <p>Hi Scott,</p><p></p><p>I learnt a lot last year going through your Data Access tutorials here. It meant I could have my first .NET project with a proper DAL, BLL and Presentation Layer and I was very happy with the results. But I am revisiting it now having read more around the subject of layering applications and now I am confused about something.</p><p></p><p>You have code in the Presentation Layer that access type declarations from the DAL.  One example is on this page:</p><p></p><p>protected string DisplayDaysOnJob(Northwind.EmployeesRow employee)</p><p>    {</p><p>        // Make sure HiredDate is not null... if so, return &quot;Unknown&quot;</p><p>        if (employee.IsHireDateNull())</p><p>            return &quot;Unknown&quot;;</p><p>        else</p><p>        {</p><p>            // Returns the number of days between the current </p><p>            // date/time and hiredDate</p><p>            TimeSpan ts = DateTime.Now.Subtract(employee.HireDate);</p><p>            return ts.Days.ToString(&quot;#,##0&quot;);</p><p>        }</p><p>    }</p><p></p><p>The Northwind class is defined in the DAL, not the BLL. So why is it OK for a code-behind in the Presentation Layer to access the DAL for the EmployeesRow type? Is it because it doesn&#39;t call any database code, but just uses those classes just to store strongly typed data in the Presentation Layer? Or does this technically break the DAL/BLL/Presentation layers but you don&#39;t think it is an issue? If so, why not?</p><p></p><p>I was considering ways to avoid this using a separate Model assembly that would be inherited by both the BLL and the DAL and passing everything around as collections of objects rather than data tables, but I think this would open a large can of worms. So I&#39;m hoping this is my misunderstanding of the separation that the layers should have.</p><p></p><p>Thanks.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/BillLH.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by payini</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Thu, 21 Oct 2010 12:04:45 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000010696</guid><description><![CDATA[ <p>Great tutorials. I learned A LOT from this tutorials. :D</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/payini.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by longqinsi</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Thu, 09 Dec 2010 08:29:52 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000011158</guid><description><![CDATA[ <p>I used Eval in Step 4 via nullable type. Code and markup are as below:</p><p>Markup:</p><p>            &lt;asp:TemplateField HeaderText=&quot;Days On The Job&quot;&gt;</p><p>                &lt;ItemTemplate&gt;</p><p>                    &lt;%# DisplayDaysOnJob((DateTime?)Eval(&quot;HireDate&quot;))%&gt;</p><p>                &lt;/ItemTemplate&gt;</p><p>            &lt;/asp:TemplateField&gt;</p><p>Code:</p><p>        protected string DisplayDaysOnJob(DateTime? hireDate)</p><p>        {</p><p>            // Make sure HiredDate is not null... if so, return &quot;Unknown&quot;</p><p>            if (hireDate == null || !hireDate.HasValue)</p><p>                return &quot;Unknown&quot;;</p><p>            else</p><p>            {</p><p>                // Returns the number of days between the current</p><p>                // date/time and HireDate</p><p>                TimeSpan ts = DateTime.Now.Subtract(hireDate.Value);</p><p>                return ts.Days.ToString(&quot;#,##0&quot;);</p><p>            }</p><p>        }</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/longqinsi.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by longqinsi</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Thu, 09 Dec 2010 09:37:51 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000011159</guid><description><![CDATA[ <p>I&#39;m sorry that last post is wrong. The means via Nullable type doesn&#39;t work.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/longqinsi.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by longqinsi</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Thu, 09 Dec 2010 09:40:58 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000011160</guid><description><![CDATA[ <p></p><p>&lt;asp:Calendar ID=&quot;Calendar1&quot; runat=&quot;server&quot; Enabled=&quot;False&quot; </p><p>  SelectedDate=&#39;&lt;%#  Eval(&quot;HireDate&quot;) is System.DateTime?(System.DateTime)Eval(&quot;HireDate&quot;):System.DateTime.Today %&gt;&#39;</p><p>  VisibleDate=&#39;&lt;%#  Eval(&quot;HireDate&quot;) is System.DateTime?(System.DateTime)Eval(&quot;HireDate&quot;):System.DateTime.Today %&gt;&#39;</p><p>  Visible=&#39;&lt;%#  Eval(&quot;HireDate&quot;) is System.DateTime %&gt;&#39;&gt;</p><p>&lt;/asp:Calendar&gt;</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/longqinsi.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by longqinsi</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Thu, 09 Dec 2010 09:43:04 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000011161</guid><description><![CDATA[ <p>Last Post is solution to brownre&#39;s problem when HireDate is NULL.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/longqinsi.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by axelnelson</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Mon, 24 Jan 2011 05:13:36 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000011734</guid><description><![CDATA[ <p>excellent tutorial scott and exactly what newbie me needed on the subjext - john montgomery - sydney australia </p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/axelnelson.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by asadazmat</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Mon, 14 Feb 2011 11:46:18 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012042</guid><description><![CDATA[ <p>From GridView designer, SelectedValue and VisibleValue of HireDate template field were not active, however they worked well from code behind by setting these values.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/asadazmat.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by IKeepWonder</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Fri, 23 Sep 2011 05:50:53 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014247</guid><description><![CDATA[ <p>To asadazmat:</p><p>Hi,I had the same problem.</p><p>I solved it by clicking _Refresh Schema_ in the left-down corner of the EditDataBindings window.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/IKeepWonder.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Anthraxmonki</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Thu, 15 Mar 2012 08:46:21 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015130</guid><description><![CDATA[ <p>Thank You! Love the article; easy to read; clear examples &amp; images; thorough. Will be sharing =D</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/Anthraxmonki.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ahmedwoye</title><link>http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs</link><pubDate>Fri, 18 May 2012 04:54:42 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015553</guid><description><![CDATA[ <p>very informative. find it so useful for young developers like myself.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/ahmedwoye.jpg?forceidenticon=false&amp;dt=635045713200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item></channel></rss>