<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Dinowebs</title>
	
	<link>http://dinowebs.net</link>
	<description>ASP.NET Tips &amp; Web Development</description>
	<lastBuildDate>Wed, 16 Jun 2010 14:39:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/dinowebs" /><feedburner:info uri="dinowebs" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>dinowebs</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Generating Random Colors in VB.NET</title>
		<link>http://feedproxy.google.com/~r/dinowebs/~3/Juagpj2mIPg/</link>
		<comments>http://dinowebs.net/?p=54#comments</comments>
		<pubDate>Wed, 16 Jun 2010 14:34:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Random()]]></category>
		<category><![CDATA[add leading zeros]]></category>
		<category><![CDATA[convert int to hex]]></category>
		<category><![CDATA[convert integer to hexadecimal]]></category>
		<category><![CDATA[hex colors]]></category>
		<category><![CDATA[int to hex]]></category>
		<category><![CDATA[leading zero]]></category>
		<category><![CDATA[random color]]></category>
		<category><![CDATA[random hex value]]></category>
		<category><![CDATA[random integer]]></category>

		<guid isPermaLink="false">http://dinowebs.net/?p=54</guid>
		<description><![CDATA[Here's how to generate a random color in the hex RGB format "#FFFFFF".]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to generate a random color in the <abbr title="hexadecimal">hex</abbr> <abbr title="Red Green Blue">RGB</abbr> format &#8220;#FFFFFF&#8221;.</p>
<p>Firstly, we generate random integer values from 0 to 255 for each color channel, red, green and blue:</p>
<div class="code">
Dim RandomClass As New Random()<br />
Dim intR, intG, intB As Integer<br />
intR = RandomClass.Next(0, 256)<br />
intG = RandomClass.Next(0, 256)<br />
intB = RandomClass.Next(0, 256)</div>
<p>With random numbers you need to give two values. The range returned is greater than or equal to the first value and less than the second value so (0, 256) gives a range from 0 to 255 inclusive.</p>
<p>Next, we convert these integer values to hexadecimal:</p>
<div class="code">Dim hexR, hexG, hexB, As String<br />
hexR = intR.ToString(&#8220;X&#8221;).PadLeft(2, &#8220;0&#8243;c)<br />
hexG = intG.ToString(&#8220;X&#8221;).PadLeft(2, &#8220;0&#8243;c)<br />
hexB = intB.ToString(&#8220;X&#8221;).PadLeft(2, &#8220;0&#8243;c)</div>
<p>The ToString(&#8220;X&#8221;) puts the integer into hexadecimal format. The PadLeft(2, &#8220;0&#8243;c) adds a leading zero before single character hex values, numbers 0-15 so that value 8 becomes 08. Expressing a color hex RGB value shorter than 6 digits may cause problems.</p>
<p>Finally, we put the red, green and blue values together with a hash symbol in a string:</p>
<div class="code">Dim strColor As String<br />
strColor = &#8220;#&#8221; &amp; hexR &amp; hexG &amp; hexB</div>
<p>You can then use this string value to generate random colors within your application.</p>
<p>To set the random color for web form controls you can generally use the randomly generated integer values rather than the hex format, like this:</p>
<div class="code">Label1.BackColor = Drawing.Color.FromArgb(intR, intG, intB)</div>
<img src="http://feeds.feedburner.com/~r/dinowebs/~4/Juagpj2mIPg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dinowebs.net/?feed=rss2&amp;p=54</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://dinowebs.net/?p=54</feedburner:origLink></item>
		<item>
		<title>Selecting a random database record with SQL</title>
		<link>http://feedproxy.google.com/~r/dinowebs/~3/mmUmuZSzPSo/</link>
		<comments>http://dinowebs.net/?p=50#comments</comments>
		<pubDate>Fri, 09 Apr 2010 14:01:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[DataRowView]]></category>
		<category><![CDATA[DataView]]></category>
		<category><![CDATA[NEWID()]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[TOP]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[featured product]]></category>
		<category><![CDATA[random content]]></category>
		<category><![CDATA[random data]]></category>
		<category><![CDATA[random hyperlink]]></category>
		<category><![CDATA[random link]]></category>
		<category><![CDATA[random product link]]></category>
		<category><![CDATA[random record]]></category>
		<category><![CDATA[random row]]></category>
		<category><![CDATA[random sql record]]></category>
		<category><![CDATA[retrieve random record]]></category>

		<guid isPermaLink="false">http://www.dinowebs.net/?p=50</guid>
		<description><![CDATA[Here's a "quick and dirty" way of selecting a database record at random. This can be used for things like showing a featured product or a random advert.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a &#8220;quick and dirty&#8221; way of selecting a database record at random. This can be used for things like showing a featured product or a random advert.</p>
<p>Here&#8217;s the SQL to use in your SelectCommand:</p>
<div class="code">SELECT TOP 1 * FROM table ORDER BY NEWID()</div>
<p>You can either bind a control such as a Repeater to the data source or use VB to pull data from the record and use it. Here&#8217;s an example of producing a random link in a page. ASP.NET form:</p>
<div class="code">&lt;asp:HyperLink ID=&#8221;lnkRandomProduct&#8221; runat=&#8221;server&#8221; /&gt;</div>
<p>And here&#8217;s the VB to grab the data for the single record:</p>
<div class="code">Dim dv As Data.DataView<br />
dv = CType(srcRandomCourse.Select(DataSourceSelectArguments.Empty), Data.DataView)<br />
Dim dr As Data.DataRowView = dv(0)<br />
Dim strProductName As String = CStr(dr(&#8220;product_name&#8221;))<br />
Dim strProductId As String = CStr(dr(&#8220;product_id&#8221;))</p>
<p>lnkRandomProduct.Text = strProductName<br />
lnkRandomProduct.NavigateUrl = &#8220;http://www.yoursite.com/products.aspx?id=&#8221; &amp; strProductId</p></div>
<img src="http://feeds.feedburner.com/~r/dinowebs/~4/mmUmuZSzPSo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dinowebs.net/?feed=rss2&amp;p=50</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://dinowebs.net/?p=50</feedburner:origLink></item>
		<item>
		<title>Calculating Age from Date of Birth in VB.NET</title>
		<link>http://feedproxy.google.com/~r/dinowebs/~3/z05DAD-4vh0/</link>
		<comments>http://dinowebs.net/?p=48#comments</comments>
		<pubDate>Mon, 08 Mar 2010 15:46:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DateDiff()]]></category>
		<category><![CDATA[DateInterval]]></category>
		<category><![CDATA[DateValue()]]></category>
		<category><![CDATA[Math.Floor()]]></category>
		<category><![CDATA[Now()]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[age from date of birth]]></category>
		<category><![CDATA[calculate age]]></category>
		<category><![CDATA[converting string to date]]></category>
		<category><![CDATA[date of birth]]></category>
		<category><![CDATA[date of birth to age]]></category>
		<category><![CDATA[difference between dates]]></category>
		<category><![CDATA[working with dates]]></category>

		<guid isPermaLink="false">http://www.dinowebs.net/?p=48</guid>
		<description><![CDATA[It's quite common to need to calculate a person's age from the date of birth they have entered. Here's the quick and easy way of doing it.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s quite common to need to calculate a person&#8217;s age from the date of birth they have entered. Here&#8217;s the quick and easy way of doing it:</p>
<div class="code">Dim strDOB As String<br />
strDOB = txtDateOfBirth.Text</p>
<p>Dim intAge As Integer<br />
intAge = Math.Floor(DateDiff(DateInterval.Month, DateValue(strDOB), Now()) / 12)</p>
<p>lblAge.Text = intAge</p>
</div>
<p>In this example the date of birth data is captured in a TextBox control called txtDateOfBirth. The DateDiff function calculates the difference between two dates. The arguments are the interval to focus on (here months), the first date (here the date of birth) and the second date (here the current date). The date of birth is expressed as DateValue(strDOB) to convert the string to a date format. This is then divided by 12 to give the age in years as a decimal. Finally, the introductory Math.Floor is used to round the number down to the nearest whole number.</p>
<img src="http://feeds.feedburner.com/~r/dinowebs/~4/z05DAD-4vh0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dinowebs.net/?feed=rss2&amp;p=48</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://dinowebs.net/?p=48</feedburner:origLink></item>
		<item>
		<title>Conditional Formatting in a GridView</title>
		<link>http://feedproxy.google.com/~r/dinowebs/~3/9O34wK67rUY/</link>
		<comments>http://dinowebs.net/?p=45#comments</comments>
		<pubDate>Thu, 17 Dec 2009 11:58:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Cells]]></category>
		<category><![CDATA[GridView]]></category>
		<category><![CDATA[Row]]></category>
		<category><![CDATA[cell backcolor]]></category>
		<category><![CDATA[cell forecolor]]></category>
		<category><![CDATA[conditional formatting]]></category>
		<category><![CDATA[formatting cells]]></category>
		<category><![CDATA[row backcolor]]></category>
		<category><![CDATA[row forecolor]]></category>
		<category><![CDATA[rowdatabound]]></category>

		<guid isPermaLink="false">http://www.dinowebs.net/?p=45</guid>
		<description><![CDATA[This code will allow you to change the background colour of a cell or entire row depending on certain conditions. In this example we test if the row being bound is a data row, then if the second column (indexed as 1) is equal to 0. If it is then the row&#8217;s backcolor is set]]></description>
			<content:encoded><![CDATA[<p>This code will allow you to change the background colour of a cell or entire row depending on certain conditions.</p>
<p>In this example we test if the row being bound is a data row, then if the second column (indexed as 1) is equal to 0. If it is then the row&#8217;s backcolor is set as PeachPuff and the cell itself has backcolor Salmon. Remember that cell indexing starts at 0 so that the first column is e.Row.Cells(0), the second column e.Row.Cells(1), etc.</p>
<div class="code">Protected Sub grdTable_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdTable.RowDataBound</p>
<p style="padding-left: 30px;">If e.Row.RowType = DataControlRowType.DataRow Then</p>
<p style="padding-left: 60px;">If e.Row.Cells(1).Text = &#8220;0&#8243; Then</p>
<p style="padding-left: 90px;">e.Row.BackColor = System.Drawing.Color.PeachPuff<br />
e.Row.Cells(1).BackColor = Drawing.Color.Salmon
</p>
<p style="padding-left: 60px;">End If</p>
<p style="padding-left: 30px;">End If</p>
<p>End Sub</p></div>
<p>To change the text colour simply substitute BackColor with ForeColor.</p>
<img src="http://feeds.feedburner.com/~r/dinowebs/~4/9O34wK67rUY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dinowebs.net/?feed=rss2&amp;p=45</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://dinowebs.net/?p=45</feedburner:origLink></item>
		<item>
		<title>Returning a Record Count using VB.net</title>
		<link>http://feedproxy.google.com/~r/dinowebs/~3/CDZCMkyEnYM/</link>
		<comments>http://dinowebs.net/?p=42#comments</comments>
		<pubDate>Tue, 15 Dec 2009 15:49:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[DataView]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[record count]]></category>
		<category><![CDATA[recordcount]]></category>
		<category><![CDATA[result count]]></category>
		<category><![CDATA[row count]]></category>
		<category><![CDATA[search matches]]></category>
		<category><![CDATA[total records]]></category>

		<guid isPermaLink="false">http://www.dinowebs.net/?p=42</guid>
		<description><![CDATA[When websites feature a text search and a table or list of results you will sometimes see something like: 73 records matched your search or 128 matches found. This is actually very easy to do but incredibly hard to find an easy way of doing it. Here&#8217;s how it&#8217;s done. This example is based on]]></description>
			<content:encoded><![CDATA[<p>When websites feature a text search and a table or list of results you will sometimes see something like:</p>
<p style="padding-left: 30px;"><span style="color: #008000;"><em>73 records matched your search</em></span> or <span style="color: #008000;"><em>128 matches found</em></span>.</p>
<p>This is actually very easy to do but incredibly hard to find an easy way of doing it. Here&#8217;s how it&#8217;s done.</p>
<p>This example is based on searching a company contact list.</p>
<p>Firstly, in your web form you need your DataSource and SelectCommand, for example:</p>
<div class="code">&lt;asp:SqlDataSource ID=&#8221;srcResults&#8221; runat=&#8221;server&#8221; ConnectionString=&#8221;&lt;%$ ConnectionStrings:constrConnectionString %&gt;&#8221; SelectCommand=&#8221;SELECT * FROM [contacts] WHERE [firstname] LIKE &#8216;%&#8217; + txtSearch + &#8216;%&#8217; OR [lastname] LIKE &#8216;%&#8217; + txtSearch + &#8216;%&#8217;&#8221;&gt;</div>
<p>Then, in your VB you get the number of records returned as follows:</p>
<div class="code">Dim intMatches As Integer<br />
Dim dv As Data.DataView<br />
dv = CType(srcResults.Select(DataSourceSelectArguments.Empty), Data.DataView)<br />
intMatches = dv.Count.ToString()</div>
<p>You will need to change srcResults in the third line to the ID of your DataSource control, the rest of the code can stay as it is.</p>
<p>Finally, you need to output the number of records to the page. This can be done by putting a Literal or Label control in the web form:</p>
<div class="code">&lt;asp:Literal ID=&#8221;litRecordCountText&#8221; runat=&#8221;server&#8221; /&gt;</div>
<p>Here&#8217;s some code which gives different output depending on whether there are 0, 1 or more than 1 record counted:</p>
<div class="code">If intMatches = 0 Then<br />
litRecordCountText.Text = &#8220;&lt;span style=&#8217;color:&#8217;cc0000&#8242;&gt;Sorry, no contacts matched your search text.&lt;br /&gt;Try entering just the first few letters of a name.&lt;/span&gt;&#8221;<br />
ElseIf intMatches = 1 Then<br />
litRecordCountText.Text = &#8220;1 match found. The following contact matches your search.&#8221;<br />
Else<br />
litRecordCountText.Text = intMatches &amp; &#8221; matches found. The following contacts match your search.&#8221;<br />
End If</div>
<img src="http://feeds.feedburner.com/~r/dinowebs/~4/CDZCMkyEnYM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dinowebs.net/?feed=rss2&amp;p=42</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://dinowebs.net/?p=42</feedburner:origLink></item>
		<item>
		<title>Using fieldsets for style</title>
		<link>http://feedproxy.google.com/~r/dinowebs/~3/sSuojT2Zfb8/</link>
		<comments>http://dinowebs.net/?p=32#comments</comments>
		<pubDate>Tue, 09 Jun 2009 12:09:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mozilla CSS]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[fieldset]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[legend]]></category>
		<category><![CDATA[fieldset tag]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[IE7]]></category>
		<category><![CDATA[legend tag]]></category>
		<category><![CDATA[moz-border-radius]]></category>
		<category><![CDATA[rounded corners]]></category>
		<category><![CDATA[tag]]></category>

		<guid isPermaLink="false">http://www.dinowebs.net/?p=32</guid>
		<description><![CDATA[There's a tag in HTML which isn't very well known called <fieldset> which can be used to create some nice visual effects with having to use images or lines and lines of JavaScript.</fieldset>]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a tag in HTML which isn&#8217;t very well known called &lt;fieldset&gt; which can be used to create some nice visual effects with having to use images or lines and lines of JavaScript.</p>
<p>Fieldset is basically used to group different elements in a form. It draws a box around content.</p>
<fieldset>Here is an example.</fieldset>
<p>In IE7 by default it renders a box with a thin grey border and rounded corners. In Firefox by default it renders a box with a thin grey border but normal square corners. The corners can easily be rounded for Firefox with a  bit of Mozilla specific CSS:</p>
<div class="code">fieldset<br />
{<br />
-moz-border-radius:10px;<br />
}</div>
<p>The 10px can be changed to create different amound of curvature. This means you have an area on screen with rounded corners without using any images or JavaScript, just simple HTML and CSS.</p>
<p>There&#8217;s another HTML tag which can add a heading to the &lt;fieldset&gt; tag. This is the &lt;legend&gt; tag.</p>
<p>This renders by default as the legend wording sitting within the border top, breaking the border.</p>
<fieldset style="-moz-border-radius:10px">
<legend>Here is the legend</legend>
<p>Here is the fieldset content.<br />
</fieldset>
<p>This can be a very effective way of heading a section especially with the right styling. This effect of breaking the border and positioning the heading text over it would use a few lines of CSS.</p>
<p>Here is the HTML code:</p>
<div class="code">&lt;fieldset&gt;<br />
&lt;legend&gt;Here is the legend&lt;/legend&gt;<br />
Here is the fieldset content.<br />
&lt;/fieldset&gt;</div>
<p><strong>Example</strong></p>
<p>You can see an example of fieldsets in use on this <a title="Corporate Hospitality" href="http://www.corporatehospitalitydirectory.com" target="_blank">Corporate Hospitality</a> website. This adds a border and a different colour to the &lt;legend&gt; tag.</p>
<img src="http://feeds.feedburner.com/~r/dinowebs/~4/sSuojT2Zfb8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dinowebs.net/?feed=rss2&amp;p=32</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://dinowebs.net/?p=32</feedburner:origLink></item>
		<item>
		<title>Confirming delete actions in ASP.NET</title>
		<link>http://feedproxy.google.com/~r/dinowebs/~3/U61Wco4Qw3s/</link>
		<comments>http://dinowebs.net/?p=27#comments</comments>
		<pubDate>Thu, 19 Mar 2009 12:16:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ButtonField]]></category>
		<category><![CDATA[DeleteCommand]]></category>
		<category><![CDATA[GridView]]></category>
		<category><![CDATA[OnClientClick]]></category>
		<category><![CDATA[TemplateField]]></category>
		<category><![CDATA[are you sure]]></category>
		<category><![CDATA[cancel]]></category>
		<category><![CDATA[confirm delete]]></category>
		<category><![CDATA[confirmation]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[delete confirm]]></category>
		<category><![CDATA[gridview]]></category>
		<category><![CDATA[message box]]></category>
		<category><![CDATA[ok]]></category>

		<guid isPermaLink="false">http://www.dinowebs.net/?p=27</guid>
		<description><![CDATA[When working with databases and the SQL DeleteCommand it may be a good idea to double check that this is what the user intended to do before risking permanently losing data.]]></description>
			<content:encoded><![CDATA[<p>When working with databases and the SQL DeleteCommand it may be a good idea to double check that this is what the user intended to do before risking permanently losing data. This is normally in the form of a pop up confirmation message with options of OK or Cancel.</p>
<p>It&#8217;s very easy to implement. Here&#8217;s how it&#8217;s done. This example has a delete button in a GridView control.</p>
<div class="code">&lt;asp:GridView ID=&#8221;grdContactNames&#8221; runat=&#8221;server&#8221; DataSourceID=&#8221;srcContacts&#8221; AutoGenerateColumns=&#8221;false&#8221; DataKeyNames=&#8221;ID&#8221;&gt;<br />
&lt;Columns&gt;<br />
&lt;asp:BoundField DataField=&#8221;ID&#8221; HeaderText=&#8221;ID&#8221; /&gt;<br />
&lt;asp:BoundField DataField=&#8221;FirstName&#8221; HeaderText=&#8221;First Name&#8221; /&gt;<br />
&lt;asp:BoundField DataField=&#8221;LastName&#8221; HeaderText=&#8221;Last Name&#8221; /&gt;<br />
&lt;asp:TemplateField&gt;<br />
&lt;ItemTemplate&gt;<br />
&lt;asp:Button ID=&#8221;btnDelete&#8221; runat=&#8221;server&#8221; Text=&#8221;Delete&#8221; CommandName=&#8221;Delete&#8221; OnClientClick=&#8221;return confirm(&#8216;Are you sure you want to delete this contact? Click OK to delete, Cancel to stop.&#8217;);&#8221; /&gt;<br />
&lt;/ItemTemplate&gt;<br />
&lt;/asp:TemplateField&gt;<br />
&lt;/Columns&gt;<br />
&lt;/asp:GridView&gt;</div>
<p>Instead of using a ButtonField as you might expect we use a TemplateField which allows us to add the OnClientClick property. You can then add your own confirmation message. The data record will only be deleted on confirming by clicking OK. No changes to the data source control are needed.</p>
<img src="http://feeds.feedburner.com/~r/dinowebs/~4/U61Wco4Qw3s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dinowebs.net/?feed=rss2&amp;p=27</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://dinowebs.net/?p=27</feedburner:origLink></item>
		<item>
		<title>Setting the page title dynamically in ASP.NET</title>
		<link>http://feedproxy.google.com/~r/dinowebs/~3/oZlHXmZKxb0/</link>
		<comments>http://dinowebs.net/?p=22#comments</comments>
		<pubDate>Thu, 12 Mar 2009 15:46:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[DataRowView]]></category>
		<category><![CDATA[DataView]]></category>
		<category><![CDATA[MasterPage]]></category>
		<category><![CDATA[Page.Header.Title]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[bind data to page title]]></category>
		<category><![CDATA[databound page title]]></category>
		<category><![CDATA[dynamic page title]]></category>
		<category><![CDATA[page header]]></category>
		<category><![CDATA[page title]]></category>
		<category><![CDATA[product name in title]]></category>
		<category><![CDATA[set page title]]></category>
		<category><![CDATA[set title]]></category>

		<guid isPermaLink="false">http://www.dinowebs.net/?p=22</guid>
		<description><![CDATA[With a database driven site it's very useful if pages giving details of a specific product have that product name in the page title.]]></description>
			<content:encoded><![CDATA[<p>With a database driven site it&#8217;s very useful if pages giving details of a specific product have that product name in the page title.</p>
<p>This sounds like it should be quite easy but it isn&#8217;t. You can insert data from a field into a page quite easily by binding the data to a control. However, the ASP.NET controls have to sit with the &lt;form&gt; tags in the &lt;body&gt; of the HTML so binding data to the &lt;head&gt; section is more difficult.</p>
<p>It has to be done programmatically. Here how&#8217;s it&#8217;s done in VB.</p>
<div class="code">Dim dv As Data.DataView<br />
dv = CType(srcDataSourceControl.Select(DataSourceSelectArguments.Empty), Data.DataView)<br />
Dim dr As Data.DataRowView = dv(0)<br />
Dim strProductName As String = CStr(dr(&#8220;ProductName&#8221;))<br />
Dim strProductNumber As String = CStr(dr(&#8220;ProductNumber&#8221;))<br />
Dim strProductCategory As String = CStr(dr(&#8220;ProductCategory&#8221;))<br />
Page.Header.Title = strProductName &amp; &#8221; &#8211; &#8221; &amp; strProductNumber &amp; &#8221; &#8211; &#8221; &amp; strProductCategory</div>
<p>This example uses srcDataSourceControl as the data source control and assumes that the database table has fields called ProductName, ProductNumber and ProductCategory. You can bind as many fields as you like in this way.</p>
<p>The title is set by giving a string value to Page.Header.Title. This can be strings bound with DataView (strProductName) or bits of text in quote marks (&#8221; &#8211; &#8220;) joined by the &amp; sign.</p>
<p>One final important thing. The &lt;head&gt; section in your page HTML must include the runat=&#8221;server&#8221; to enable the header content to be manipulated on the server side.</p>
<div class="code">&lt;head runat=&#8221;server&#8221;&gt;</div>
<img src="http://feeds.feedburner.com/~r/dinowebs/~4/oZlHXmZKxb0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dinowebs.net/?feed=rss2&amp;p=22</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://dinowebs.net/?p=22</feedburner:origLink></item>
		<item>
		<title>Showing only present and future dates using SelectCommand in ASP.NET</title>
		<link>http://feedproxy.google.com/~r/dinowebs/~3/lmlRH90XhLI/</link>
		<comments>http://dinowebs.net/?p=12#comments</comments>
		<pubDate>Wed, 11 Mar 2009 11:15:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SelectCommand]]></category>
		<category><![CDATA[date filtering]]></category>
		<category><![CDATA[date value]]></category>
		<category><![CDATA[datevalue]]></category>
		<category><![CDATA[future dates]]></category>

		<guid isPermaLink="false">http://www.dinowebs.net/?p=12</guid>
		<description><![CDATA[Where you have a database of events you can easily exclude those which have gone by leaving only current and future events. However, getting the SelectCommand syntax right is not obvious.]]></description>
			<content:encoded><![CDATA[<p>Where you have a database of events you can easily exclude those which have gone by leaving only current and future events. However, getting the SelectCommand syntax right is not obvious.</p>
<div class="code">SelectCommand=&#8221;SELECT  [EventName], [EventDate] FROM [EventsTable] WHERE DateValue([EventDate]) &gt;= DATE() ORDER BY [EventDate]&#8220;</div>
<p>To show only current and future events add DateValue([EventDate]) &gt;= DATE() to the WHERE clause of your data source SelectCommand. DateValue grabs the date value of your date field, DATE() returns today&#8217;s date.</p>
<p>This can be varied to show dates in the past by changing the operator from &#8220;&gt;=&#8221; to &#8220;&lt;&#8221; or past and present &#8220;&lt;=&#8221;.</p>
<p>Works with ASP.NET 2.0 or higher.</p>
<img src="http://feeds.feedburner.com/~r/dinowebs/~4/lmlRH90XhLI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dinowebs.net/?feed=rss2&amp;p=12</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://dinowebs.net/?p=12</feedburner:origLink></item>
		<item>
		<title>Category links with record count in ASP.NET</title>
		<link>http://feedproxy.google.com/~r/dinowebs/~3/NHsYhNtcvrs/</link>
		<comments>http://dinowebs.net/?p=3#comments</comments>
		<pubDate>Wed, 11 Mar 2009 09:58:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[AccessDataSource]]></category>
		<category><![CDATA[DataList]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SelectCommand]]></category>
		<category><![CDATA[category list]]></category>
		<category><![CDATA[list record count]]></category>
		<category><![CDATA[record count]]></category>
		<category><![CDATA[select count]]></category>

		<guid isPermaLink="false">http://www.dinowebs.net/?p=3</guid>
		<description><![CDATA[Here's how to show a list of links with the number of records shown in brackets. This is actually very simple but you can really get tied up in knots if you don't get the SQL SelectCommand right.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to show a list of links with the number of records shown in brackets. You can see a working example at <a title="Corporate Hospitality Directory" href="http://www.corporatehospitalitydirectory.com" target="_blank">http://www.corporatehospitalitydirectory.com</a>.</p>
<p>This is actually very simple but you can really get tied up in knots if you don&#8217;t get the SQL SelectCommand right.</p>
<p>You can use any of the list controls for this but here I&#8217;ve chosen the DataList control.</p>
<div class="code">&lt;asp:DataList ID=&#8221;dalCategories&#8221; runat=&#8221;server&#8221; DataSourceID=&#8221;srcCategories&#8221; RepeatColumns=&#8221;4&#8243; RepeatDirection=&#8221;Vertical&#8221;&gt;<br />
&lt;ItemTemplate&gt;<br />
&lt;a href=&#8221;ShowEvents.aspx?cat=&lt;%#Eval(&#8220;Category&#8221;)%&gt;&#8221;&gt;<br />
&lt;%#Eval(&#8220;Category&#8221;)%&gt;&lt;/a&gt; (&lt;%#Eval(&#8220;RecordCount&#8221;)%&gt;)<br />
&lt;/ItemTemplate&gt;<br />
&lt;/asp:DataList&gt;</div>
<p>In this example, the DataList gets its data from the srcCategories AccessDataSource control but you could equally use any of the ASP.NET  2.0+ data source controls. Within the item template the &#8220;Category&#8221; value is used in the link URL and link text and the &#8220;RecordCount&#8221; value appears after the link in brackets.</p>
<p>The DataList control renders an HTML table and the RepeatColumns and RepeatDirection attributes just vary the layout of this table.</p>
<div class="code">&lt;asp:AccessDataSource ID=&#8221;srcCategories&#8221; runat=&#8221;server&#8221; DataFile=&#8221;database.mdb&#8221;<br />
SelectCommand=&#8221;SELECT DISTINCT [Category], COUNT(ID) AS RecordCount FROM [EventsTable] GROUP BY [Category] ORDER BY [Category]&#8220;&gt;<br />
&lt;/asp:AccessDataSource&gt;</div>
<p>The AccessDataSource control&#8217;s SelectCommand uses DISTINCT [Category] to show each category name only once, then a COUNT of the ID field named as RecordCount for use in the DataList control.</p>
<p>Works with ASP.NET 2.0 or higher.</p>
<img src="http://feeds.feedburner.com/~r/dinowebs/~4/NHsYhNtcvrs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dinowebs.net/?feed=rss2&amp;p=3</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://dinowebs.net/?p=3</feedburner:origLink></item>
	</channel>
</rss>
