﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>ASP.net</title>
    <description>VB and a little C#</description>
    <link>http://www.rmc-solutions.co.uk/Home/tabid/36/BlogId/1/Default.aspx</link>
    <language>en-US</language>
    <webMaster>admin@rmc-solutions.co.uk</webMaster>
    <pubDate>Wed, 01 Oct 2008 00:43:07 GMT</pubDate>
    <lastBuildDate>Wed, 01 Oct 2008 00:43:07 GMT</lastBuildDate>
    <docs>http://backend.userland.com/rss</docs>
    <generator>Blog RSS Generator Version 3.4.0.39853</generator>
    <item>
      <title> Datagrid Output Formatting</title>
      <description>&lt;p&gt;&lt;span style="font-size: 9pt" __designer:mapid="1"&gt;Most of the applications which I develop are report driven, time critical information systems. For this reason I have always found it useful to be able to format the output of a datagrid at runtime. In most cases, I will just change the background colour of a cell\row, in other cases I will change the text depending on the criteria.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: 10pt"&gt;&lt;strong&gt;Merging Two Fields&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
Firstly you will need this function in your code page.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #000000"&gt;&lt;span style="font-family: Courier New"&gt;&lt;span&gt;Protected&lt;/span&gt;&lt;span style="font-weight: 400"&gt;Function&lt;/span&gt;&lt;/span&gt;&lt;span&gt; createFullName(&lt;/span&gt;&lt;span style="font-weight: 400; font-family: Courier New"&gt;ByVal&lt;/span&gt;&lt;span&gt; fName &lt;/span&gt;&lt;span style="font-weight: 400; font-family: Courier New"&gt;As&lt;/span&gt;&lt;span style="font-weight: 400; font-family: Courier New"&gt;Object&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style="font-weight: 400; font-family: Courier New"&gt;ByVal&lt;/span&gt;&lt;span&gt; sName &lt;/span&gt;&lt;span style="font-weight: 400; font-family: Courier New"&gt;As&lt;/span&gt;&lt;span style="font-weight: 400; font-family: Courier New"&gt;Object&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span style="font-weight: 400; font-family: Courier New"&gt;As&lt;/span&gt;&lt;span style="font-weight: 400; font-family: Courier New"&gt;String&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span __designer:mapid="2"&gt;&lt;br /&gt;
&lt;span style="font-size: 9pt; color: #000000"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt" __designer:mapid="3"&gt;&lt;span style="color: #000000"&gt;&lt;span&gt; &lt;/span&gt;&lt;span style="font-weight: 400; font-family: Courier New"&gt;Return CType&lt;span style="font-family: Arial"&gt;(fName, &lt;/span&gt;&lt;span style="font-weight: 400; font-family: Courier New"&gt;String) &amp; " " &amp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: 400; font-family: Courier New"&gt;CType&lt;/span&gt;&lt;span&gt;(sName, &lt;/span&gt;&lt;span style="font-weight: 400; font-family: Courier New"&gt;String&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt" __designer:mapid="4"&gt;&lt;span style="color: #000000"&gt;&lt;span&gt;)&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-weight: 400; font-family: Courier New"&gt;End&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: 400; font-size: 12px; color: #0000ff; font-family: Courier New" __designer:mapid="5"&gt;&lt;span style="font-size: 9pt"&gt;&lt;span style="color: #000000"&gt;Function&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-size: 8pt; color: #000000; font-family: Arial"&gt;&lt;span style="font-size: 9pt"&gt;In Order to call this function you need to change the text properties of the label field.&lt;br /&gt;
&lt;br /&gt;
&lt;asp:Label runat="server" Text='&lt;%# createFullName(DataBinder.Eval(Container, "DataItem.Forename"), DataBinder.Eval(Container, "DataItem.Surname")) %&gt;'&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-size: 10pt"&gt;Changing Cell Properties&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
In this example I am changing the back color depending on whether a target has been met.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: 8pt; font-family: Courier New"&gt;Protected Sub gV_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-size: 8pt"&gt;&lt;span style="font-family: Courier New"&gt;   tempDays = DateDiff(DateInterval.Day, Now(), tempdate) &lt;br /&gt;
   If e.Row.RowType = DataControlRowType.DataRow Or e.Row.RowType = DataControlRowType.Header Then &lt;br /&gt;
       If e.Row.Cells(2).Text &lt;&gt; "" Then &lt;br /&gt;
         tempdate = DateTime.Parse(e.Row.Cells(2).Text) &lt;br /&gt;
         tempDays = DateDiff(DateInterval.Day, Now(), tempdate) &lt;br /&gt;
          If tempDays &lt; 0 Then &lt;br /&gt;
            e.Row.BackColor = Drawing.Color.Red &lt;br /&gt;
         End If &lt;br /&gt;
         If tempDays &gt;= 0 And tempDays &lt; 5 Then &lt;br /&gt;
            e.Row.BackColor = Drawing.Color.Orange &lt;br /&gt;
         End If &lt;br /&gt;
         If tempDays &gt; 4 Then &lt;br /&gt;
            e.Row.BackColor = Drawing.Color.LightGreen &lt;br /&gt;
         End If &lt;br /&gt;
      End If &lt;br /&gt;
   End If&lt;br /&gt;
End Sub&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description>
      <link>http://www.rmc-solutions.co.uk/Home/tabid/36/EntryID/1/Default.aspx</link>
      <comments>http://www.rmc-solutions.co.uk/Home/tabid/36/EntryID/1/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.rmc-solutions.co.uk/Default.aspx?tabid=36&amp;EntryID=1</guid>
      <pubDate>Thu, 12 Jun 2008 18:40:00 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rmc-solutions.co.uk/DesktopModules/Blog/Trackback.aspx?id=1</trackback:ping>
    </item>
  </channel>
</rss>