<?xml version="1.0" encoding="UTF-8"?>
<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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Castner IT Blog &#187; ASP.NET</title>
	<atom:link href="http://www.castnerit.com.au/blog/category/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.castnerit.com.au/blog</link>
	<description>ASP.NET, SEO, Small Business IT</description>
	<lastBuildDate>Thu, 12 Jan 2012 21:59:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Microsoft SQL Server and Joomla 2.5</title>
		<link>http://www.castnerit.com.au/blog/2012/01/microsoft-sql-server-and-joomla-2-5/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=microsoft-sql-server-and-joomla-2-5</link>
		<comments>http://www.castnerit.com.au/blog/2012/01/microsoft-sql-server-and-joomla-2-5/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 20:46:40 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Small Business]]></category>
		<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>

		<guid isPermaLink="false">http://www.castnerit.com.au/blog/?p=212</guid>
		<description><![CDATA[Joomla 2.5 is set to be released on 24 January. One of the new features is Joomla now supports the Microsoft SQL database in addition to mySQL (and others) as its content database. This new feature provides great opportunities for tighter integration of your public web site with your back-end systems running MS SQL. For [...]]]></description>
			<content:encoded><![CDATA[<p>Joomla 2.5 is set to be released on 24 January. One of the new features is Joomla now supports the Microsoft SQL database in addition to mySQL (and others) as its content database. This new feature provides great opportunities for tighter integration of your public web site with your back-end systems running MS SQL.</p>
<p>For example, one of my clients, pd training, uses Joomla for its public web site (www.pdtraining.com.au) and an ASP.NET/MSSQL-based system for its booking and learning management systems (bookings.pdtraining.com.au). Integration between the two systems has been limited. We have used both the <a title="Table JX plugin" href="http://extensions.joomla.org/extensions/core-enhancements/data-reports/10340" target="_blank">Table JX plugin</a> and iframes to display class schedules from the MS SQL database.</p>
<p>With the ability of Joomla 2.5 to run off Microsoft SQL server, we can now have our class schedule data in the same MS SQL database as our joomla content, opening up more opportunities for integration between course descriptions and class schedules. While this of course was all possible in mySQL and php with MSSQL drivers, we can now work with a single db platform. This will  reduce overhead and duplication of effort.</p>
<p>Other opportunities include converting your Microsoft Access database to Microsoft SQL server and integrating that data with your Joomla web site.</p>
<p>Feel free to email or call us if you want more information.</p>
<p>By the way, here is a list of the other new features in Joomla 2.5: http://blog.templatemonster.com/2012/01/12/joomla-2-5-new-features/</p>
<p>One more thing. You will need windows hosting to run Joomla with Microsoft SQL Server. A great hosting company that does this is studiocoast.com.au (full disclosure: I am a reseller). I host my site and many of my client&#8217;s sites with studiocoast. Check out <a title="Studiocoast Order Form" href="https://secure.hostcontrol.com.au/order/order.aspx?ResellerID=1D9C721DC9A2" target="_blank">studiocoast&#8217;s services</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2012/01/microsoft-sql-server-and-joomla-2-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NSW Election Sausage Sizzle Map</title>
		<link>http://www.castnerit.com.au/blog/2011/03/nsw-election-sausage-sizzle-map/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nsw-election-sausage-sizzle-map</link>
		<comments>http://www.castnerit.com.au/blog/2011/03/nsw-election-sausage-sizzle-map/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 12:19:09 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Small Business]]></category>
		<category><![CDATA[Social Media]]></category>
		<category><![CDATA[NSW election]]></category>
		<category><![CDATA[Sausage Sizzle Map]]></category>

		<guid isPermaLink="false">http://www.castnerit.com.au/blog/?p=192</guid>
		<description><![CDATA[After successful maps for the federal and Victorian elections, I am again running the sausage sizzle and cake stall map for the 2011 NSW election. It is a great way to demonstrate a range of online topics for small business including: Search Engine Optimisation Google Analytics Social Media Integration Google Maps Integration ASP.NET SQL Server [...]]]></description>
			<content:encoded><![CDATA[<p>After successful maps for the federal and Victorian elections, I am again running the sausage sizzle and cake stall map for the 2011 NSW election. It is a great way to demonstrate a range of online topics for small business including:</p>
<ul>
<li>Search Engine Optimisation</li>
<li>Google Analytics</li>
<li>Social Media Integration</li>
<li>Google Maps Integration</li>
<li>ASP.NET</li>
<li>SQL Server</li>
<li>Google Adwords</li>
</ul>
<p>The map has already been mentioned by ABC 702 Sydney radio. Hopefully it will generate similar interest as the previous two maps, including an interview with Noni Hazelhurst on ABC morning radio in Melbourne.</p>
<p>The map is available at <a href="http://www.electionsausagesizzle.com.au">http://www.electionsausagesizzle.com.au</a>. This link also allows schools and other polling venues to add their cake stall or sausage sizzle as a means of promoting their fundraising efforts.</p>
<p>Finally, its a bit of fun to seeing how much interest it attracts and it looks like I will be doing it for a Queensland state election soon.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2011/03/nsw-election-sausage-sizzle-map/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show/Hide and Search Columns in GridView with CheckBoxList and QueryExtender</title>
		<link>http://www.castnerit.com.au/blog/2010/11/showhide-and-search-columns-in-gridview-with-checkboxlist-and-queryextender/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=showhide-and-search-columns-in-gridview-with-checkboxlist-and-queryextender</link>
		<comments>http://www.castnerit.com.au/blog/2010/11/showhide-and-search-columns-in-gridview-with-checkboxlist-and-queryextender/#comments</comments>
		<pubDate>Sun, 31 Oct 2010 17:05:27 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[CheckBoxList]]></category>
		<category><![CDATA[GridView]]></category>
		<category><![CDATA[QueryExtender]]></category>

		<guid isPermaLink="false">http://www.castnerit.com.au/blog/?p=166</guid>
		<description><![CDATA[A client recently asked for an ASP.NET page that would provide flexible and ad-hoc reporting functionality. Specifically, the client wanted to be able to: Choose from over 20 data columns to show/hide in a gridview Filter data by date ranges Search over multiple columns Total amount columns based on the search and filter criteria Show/Hide [...]]]></description>
			<content:encoded><![CDATA[<p>A client recently asked for an ASP.NET page that would provide flexible and ad-hoc reporting functionality. Specifically, the client wanted to be able to:</p>
<ul>
<li>Choose from over 20 data columns to show/hide in a gridview</li>
<li>Filter data by date ranges</li>
<li>Search over multiple columns</li>
<li>Total amount columns based on the search and filter criteria</li>
</ul>
<h2>Show/Hide Columns in GridView</h2>
<p>Declan Bright&#8217;s post on codeproject &#8211; <a href="http://www.codeproject.com/KB/webforms/ShowHideGridviewColumns.aspx">http://www.codeproject.com/KB/webforms/ShowHideGridviewColumns.aspx</a> &#8211; was an excellent starting point. My clients wanted to be able to show or hide columns from a single checkboxlist rather than a combination of controls in the gridview header and a dropdownlist.</p>
<p>Below is the code for the GridView&#8217;s RowCreated event. The first part creates the listitems for the checkboxlist from the gridview header columns. It also selects the default columns to show when the page is first opened. All other columns are hidden. The 2nd part iterates through the checkboxlist and determines which gridview columns to display.<br />
<dirtycode><br />
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)<br />
{<br />
// Set the default hidden columns<br />
if (!IsPostBack)<br />
{<br />
if (e.Row.Cells.Count != null)<br />
{<br />
if (e.Row.RowType == DataControlRowType.Header)<br />
{<br />
// Loop through each cell of the header row<br />
for (int columnIndex = 0; columnIndex &lt; e.Row.Cells.Count; columnIndex++)<br />
{<br />
ListItem gvColumn = new ListItem();<br />
gvColumn.Text = GridView1.Columns[columnIndex].HeaderText;<br />
gvColumn.Value = columnIndex.ToString();<br />
if (gvColumn.Text == &#8220;HeaderText1&#8243; || gvColumn.Text == &#8220;HeaderText2&#8243; || gvColumn.Text == &#8220;HeaderText3&#8243; || gvColumn.Text == &#8220;HeaderText4&#8243; || gvColumn.Text == &#8220;HeaderText5&#8243;)<br />
{<br />
gvColumn.Selected = true;<br />
}<br />
CheckBoxList1.Items.Add(gvColumn);<br />
}<br />
}<br />
}<br />
}</p>
<p>// Hide the columns selected from the CheckBoxList<br />
try<br />
{<br />
foreach (ListItem li in CheckBoxList1.Items)<br />
{<br />
if (li.Selected == true)<br />
{<br />
e.Row.Cells[Convert.ToInt32(li.Value)].Visible = true;<br />
}<br />
else<br />
{<br />
e.Row.Cells[Convert.ToInt32(li.Value)].Visible = false;<br />
}<br />
}<br />
}<br />
catch (Exception ex)<br />
{<br />
Add error handling code<br />
}<br />
}<br />
</dirtycode></p>
<h2>Totals</h2>
<p>The next step is to use the GridView RowDataBound event to total 1 or more amounts columns (only 1 column totalled in this example):<br />
<dirtycode><br />
// Total Amount Column<br />
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)<br />
{<br />
if (e.Row.RowType == DataControlRowType.DataRow)<br />
{<br />
Label vL2 = e.Row.FindControl(&#8220;lqcAmount&#8221;) as Label;<br />
vTotal2 += Convert.ToDouble(vL2.Text);<br />
}</p>
<p>if (e.Row.RowType == DataControlRowType.Footer)<br />
{<br />
Label vL2 = e.Row.FindControl(&#8220;lqcAmountTotal&#8221;) as Label;<br />
vL2.Text = String.Format(&#8220;{0:#,###.00}&#8221;, vTotal2);<br />
}<br />
}<br />
</dirtycode></p>
<h2>Searching and Filtering GridView</h2>
<p>For search and filtering, a queryextender was attached to the LinqDataSource to search through string columns and filter by a number of date ranges and a status field:</p>
<p>&lt;asp:QueryExtender TargetControlID=&#8221;GridDataSource&#8221; ID=&#8221;GridQueryExtender&#8221; runat=&#8221;server&#8221;&gt;<br />
&lt;asp:SearchExpression SearchType=&#8221;Contains&#8221; DataFields=&#8221;field1,field2,field3,field4&#8243;&gt;<br />
&lt;asp:ControlParameter ControlID=&#8221;SearchTextBox&#8221; /&gt;<br />
&lt;/asp:SearchExpression&gt;<br />
&lt;asp:RangeExpression DataField=&#8221;Date1&#8243; MaxType=&#8221;Inclusive&#8221; MinType=&#8221;Inclusive&#8221;&gt;<br />
&lt;asp:ControlParameter ControlID=&#8221;tStartDate&#8221; /&gt;<br />
&lt;asp:ControlParameter ControlID=&#8221;tEndDate&#8221; /&gt;<br />
&lt;/asp:RangeExpression&gt;<br />
&lt;asp:RangeExpression DataField=&#8221;Date2&#8243; MaxType=&#8221;Inclusive&#8221; MinType=&#8221;Inclusive&#8221;&gt;<br />
&lt;asp:ControlParameter ControlID=&#8221;tStartDate2&#8243; /&gt;<br />
&lt;asp:ControlParameter ControlID=&#8221;tEndDate2&#8243; /&gt;<br />
&lt;/asp:RangeExpression&gt;<br />
&lt;asp:PropertyExpression&gt;<br />
&lt;asp:ControlParameter ControlID=&#8221;ddlStatus&#8221; PropertyName=&#8221;SelectedValue&#8221; Name=&#8221;StatusName&#8221; /&gt;<br />
&lt;/asp:PropertyExpression&gt;<br />
&lt;/asp:QueryExtender&gt;</p>
<p>Here is the markup for the search textboxes and dropdownlist:</p>
<p>&lt;table&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;Invoice Date Range:&lt;/td&gt;<br />
&lt;td&gt;&lt;asp:TextBox ID=&#8221;tStartDate&#8221; runat=&#8221;server&#8221; /&gt; &#8211; &lt;asp:TextBox ID=&#8221;tEndDate&#8221; runat=&#8221;server&#8221; /&gt;&lt;/td&gt;<br />
&lt;td&gt;&amp;nbsp;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;Followup Date Range:&lt;/td&gt;<br />
&lt;td&gt;&lt;asp:TextBox ID=&#8221;tStartDate2&#8243; runat=&#8221;server&#8221; /&gt; &#8211; &lt;asp:TextBox ID=&#8221;tEndDate2&#8243; runat=&#8221;server&#8221; /&gt;&lt;/td&gt;<br />
&lt;td&gt;&amp;nbsp;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;Search:&lt;/td&gt;<br />
&lt;td&gt;&lt;asp:TextBox ID=&#8221;SearchTextBox&#8221; runat=&#8221;server&#8221; /&gt;&lt;/td&gt;<br />
&lt;td&gt;<br />
&lt;asp:Button ID=&#8221;Button4&#8243; runat=&#8221;server&#8221; OnClick=&#8221;Button1_Click&#8221; Text=&#8221;Display&#8221; /&gt;<br />
&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;/table&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2010/11/showhide-and-search-columns-in-gridview-with-checkboxlist-and-queryextender/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Australian Election Day Polling Place Stall Finder</title>
		<link>http://www.castnerit.com.au/blog/2010/08/australian-election-day-polling-place-stall-finder/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=australian-election-day-polling-place-stall-finder</link>
		<comments>http://www.castnerit.com.au/blog/2010/08/australian-election-day-polling-place-stall-finder/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 07:23:15 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.castnerit.com/blog/2010/08/16/australian-election-day-polling-place-stall-finder/</guid>
		<description><![CDATA[A tradition at every Australian election polling place is a variety of stalls with cakes, arts and crafts, and sausage sizzles. During my lunch break today I designed a simple web application using ASP.NET and a little AJAX that will let you search for a polling place and see what stall are available. Most stalls [...]]]></description>
			<content:encoded><![CDATA[<p>A tradition at every Australian election polling place is a variety of stalls with cakes, arts and crafts, and sausage sizzles. During my lunch break today I designed a simple web application using ASP.NET and a little AJAX that will let you search for a polling place and see what stall are available. Most stalls have a fundraising focus so it allows them to promote their stall online. The link is <a href="http://www.castnerit.com/polling-booth-stall-finder/">http://www.castnerit.com/polling-booth-stall-finder/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2010/08/australian-election-day-polling-place-stall-finder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Avoiding ASP.NET dropdownlist has a selectedvalue which is invalid exceptions</title>
		<link>http://www.castnerit.com.au/blog/2010/05/avoiding-asp-net-dropdownlist-has-a-selectedvalue-which-is-invalid-exceptions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=avoiding-asp-net-dropdownlist-has-a-selectedvalue-which-is-invalid-exceptions</link>
		<comments>http://www.castnerit.com.au/blog/2010/05/avoiding-asp-net-dropdownlist-has-a-selectedvalue-which-is-invalid-exceptions/#comments</comments>
		<pubDate>Sat, 29 May 2010 13:05:06 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[dropdownlist]]></category>

		<guid isPermaLink="false">http://www.castnerit.com/blog/?p=134</guid>
		<description><![CDATA[It is often to difficult to capture the following ASP.NET dropdownlist error when the dropdownlist is bound to an sqldatasource:  Dropdownlistname has a SelectedValue which is invalid because it does not exist in the list of items  This exception is frequently caused by poor validation controls during data entry and/or poor database design. For example, the previous [...]]]></description>
			<content:encoded><![CDATA[<p>It is often to difficult to capture the following ASP.NET dropdownlist error when the dropdownlist is bound to an sqldatasource: </p>
<p><strong><em>Dropdownlistname</em> has a SelectedValue which is invalid because it does not exist in the list of items</strong> </p>
<p>This exception is frequently caused by poor validation controls during data entry and/or poor database design. For example, the previous application might have allowed invalid data combinations. In an ideal world, you would fix the validation controls or database design before data entry commenced but often (as in my case on a recent project) you have inherited a database where invalid data was allowed to slip through. </p>
<p>Once you fix the application by introducing appropriate validation controls, when users go to edit the records with invalid data, they start to receive a range of exceptions including dropdownlist selectedvalue errors. It is reasonably difficult to catch these exceptions at runtime. There are a number of solutions including: </p>
<ul>
<li>Cleaning the data</li>
<li>Adding the missing value to the database table that is the datasource for the dropdownlist.</li>
<li>Catching the exception from the ondatabind event of the dropdownlist by adding an eventhandler (see for example dynadata&#8217;s post at <a href="http://forums.asp.net/t/937399.aspx?PageIndex=2">http://forums.asp.net/t/937399.aspx?PageIndex=2</a>).</li>
</ul>
<p>Cleaning the data would be a good solution but not always possible. Adding the missing value is a quick solution but it may introduce more invalid data into the database and often the missing &#8220;value&#8221; is <em>null </em>or blank which ideally you want to avoid adding<em>.</em> Catching the error on databind is a good solution but requires changing the out of range selected value to a default value before the dropdownlist is rendered. If you are using this approach, you should warn the user that the data has been changed and display the invalid value so that the user can make note of the previous value before updating the data. </p>
<p>One alternative solution that I am exploring that doesn&#8217;t require the selected value to be changed beforehand is to rewrite the sqldatasource SELECT statement for the dropdownlist in the edit template of a formview (or other control) while leaving the insert template statement with only the valid list items. The rewritten SELECT statement for the dropdownlist sqldatasource includes a UNION operator. The second SELECT statement includes the invalid value or values. It has the benefit of not having to add the invalid records into the database and the data does not have to be changed before rendering the dropdownlist. Users could then be warned that the data is invalid and be asked (or forced) to change it to a valid value before updating the database. </p>
<p>Examples: </p>
<p>SELECT F1, F2 FROM Table1 UNION SELECT &#8221; AS F3, &#8221; AS F4 FROM Table1 AS T1 ORDER BY F1 </p>
<p>SELECT F1, F2 FROM Table1 UNION SELECT NULL  AS F3, &#8221; AS F4 FROM Table1 AS T1 ORDER BY F1 </p>
<p>The first example handles a blank value as the selected value, the second example handles <em>null</em> being the selected value.</p>
<p>Any constructive feedback on the alternative approaches is welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2010/05/avoiding-asp-net-dropdownlist-has-a-selectedvalue-which-is-invalid-exceptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Consuming a web service using ASP.NET</title>
		<link>http://www.castnerit.com.au/blog/2010/05/consuming-a-web-service-using-asp-net/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=consuming-a-web-service-using-asp-net</link>
		<comments>http://www.castnerit.com.au/blog/2010/05/consuming-a-web-service-using-asp-net/#comments</comments>
		<pubDate>Fri, 21 May 2010 00:30:54 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://castnerit.com/blog/?p=129</guid>
		<description><![CDATA[This is a video tutorial I created for my eBusiness class at the University of Oregon. It is an introduction to consuming a web service  and using the Google Maps API with ASP.NET and Visual Studio 2008. It highlights how to create and use a web reference on an ASP.NET web page with Visual Basic. It also provides [...]]]></description>
			<content:encoded><![CDATA[<p>This is a video tutorial I created for my eBusiness class at the University of Oregon. It is an introduction to consuming a web service  and using the Google Maps API with ASP.NET and Visual Studio 2008. It highlights how to create and use a web reference on an ASP.NET web page with Visual Basic. It also provides an example on how to use the RegisterStartupScript method to insert JavaScript using Visual Basic.</p>
<p>For more information on location-based services, contact the experienced staff at <a href="http://www.castnerit.com/aboutus/contactus.aspx">Castner IT</a></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/iD8WwKwc0nI&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/iD8WwKwc0nI&amp;hl=en&amp;fs=1" allowfullscreen="true" allowscriptaccess="always"></embed></object></p>
<p>YouTube Link: <a href="http://www.youtube.com/watch?v=iD8WwKwc0nI">http://www.youtube.com/watch?v=iD8WwKwc0nI</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2010/05/consuming-a-web-service-using-asp-net/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Inserting a PayPal Buy Now Button into an ASP.NET Form</title>
		<link>http://www.castnerit.com.au/blog/2008/12/inserting-a-paypal-buy-now-button-into-an-aspnet-form/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=inserting-a-paypal-buy-now-button-into-an-aspnet-form</link>
		<comments>http://www.castnerit.com.au/blog/2008/12/inserting-a-paypal-buy-now-button-into-an-aspnet-form/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 01:22:27 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>

		<guid isPermaLink="false">http://castnerit.com/blog/?p=101</guid>
		<description><![CDATA[When working with ASP.NET pages, one difficulty that often arises is that you need two forms on the page &#8211; the normal form required by ASP.NET and a second form for something else such as a PayPal button or a search tool. The solution that I discovered is to not have two forms but simply [...]]]></description>
			<content:encoded><![CDATA[<p>When working with ASP.NET pages, one difficulty that often arises is that you need two forms on the page &#8211; the normal form required by ASP.NET and a second form for something else such as a PayPal button or a search tool. The solution that I discovered is to not have two forms but simply have one form (the normal one in the master page). It usually only requires some minor changes to the controls in the 2nd form for it to work. For example, here is the adjusted code for a PayPal Buy Now button:<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;cmd&#8221; value=&#8221;_xclick&#8221; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;business&#8221; value=&#8221;<a href="mailto:gcastner@asianfoods.com">gcastner@asianfoods.com</a>&#8221; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;item_name&#8221; value=&#8221;Sweet and sour sauce&#8221;/&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;item_number&#8221; value=&#8221;SAUCE001&#8243; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;amount&#8221; value=&#8221;100.00&#8243; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;no_shipping&#8221; value=&#8221;2&#8243; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;no_note&#8221; value=&#8221;1&#8243; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;currency_code&#8221; value=&#8221;USD&#8221; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;lc&#8221; value=&#8221;US&#8221; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;bn&#8221; value=&#8221;PP-BuyNowBF&#8221; /&gt;<br />
&lt;img alt=&#8221;" style=&#8217;border:0px;&#8217; src=&#8217;<a href="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif">https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif</a>&#8221; width=&#8221;1&#8243; height=&#8221;1&#8243; /&gt;<br />
&lt;asp:Button ID=&#8221;Button2&#8243; runat=&#8221;server&#8221; Text=&#8221;Button&#8221; PostBackUrl=&#8221;<a href="https://www.sandbox.paypal.com/cgi-bin/webscr">https://www.sandbox.paypal.com/cgi-bin/webscr</a>&#8221; /&gt;</p>
<p>The main changes from the PayPal supplied code are the removal of the form tags and the inclusion of the asp:button. The reason for the change is that because ASP.NET pages are already web forms, we cannot simply add a 2nd form into the page (it would cause an error).</p>
<p>Another useful thing is that you can set the default button for the page, or different parts of the page. This example sets the default button when someone presses enter to the login button rather than the search button at the top of the page. You need to enclose the relevant controls in a panel control.</p>
<p>  Protected Sub panelLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles panelLogin.Load</p>
<p>    Page.Form.DefaultFocus = Login1.FindControl(&#8220;UserName&#8221;).UniqueID<br />
    Page.Form.DefaultButton = Login1.FindControl(&#8220;LoginButton&#8221;).UniqueID</p>
<p>  End Sub</p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2008/12/inserting-a-paypal-buy-now-button-into-an-aspnet-form/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft reporting: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.</title>
		<link>http://www.castnerit.com.au/blog/2008/10/microsoft-reporting-failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=microsoft-reporting-failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints</link>
		<comments>http://www.castnerit.com.au/blog/2008/10/microsoft-reporting-failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 13:05:04 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[Small Business Online]]></category>

		<guid isPermaLink="false">http://castnerit.com/blog/?p=87</guid>
		<description><![CDATA[This error was bugging me for a long time until I found this excellent forum discussion: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=541116&#38;SiteId=1 The following points summarize the causes and solutions from the forum and offer some additional help: 1. Check if you have changed the length of any fields in the underlying database table after creating the dataset. If you [...]]]></description>
			<content:encoded><![CDATA[<p>This error was bugging <img src='http://www.castnerit.com.au/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  me for a long time until I found this excellent forum discussion:</p>
<p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=541116&amp;SiteId=1">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=541116&amp;SiteId=1</a></p>
<p>The following points summarize the causes and solutions from the forum and offer some additional help:</p>
<p>1. Check if you have changed the length of any fields in the underlying database table after creating the dataset. If you have, you may need to manually change them in the dataset as well. If you are using Visual Studio 2008, open the xsd file and click on the relevant field name. Ensure the maxlength property matches your new field length.</p>
<div id="attachment_88" class="wp-caption aligncenter" style="width: 310px"><a href="http://castnerit.com/blog/wp-content/uploads/2008/10/clipboard03.jpg"><img class="size-medium wp-image-88" title="Check maxlength property" src="http://castnerit.com/blog/wp-content/uploads/2008/10/clipboard03-300x132.jpg" alt="Check maxlength property" width="300" height="132" /></a><p class="wp-caption-text">Check maxlength property</p></div>
<p>2. If you base your dataset off a view rather than a table, and that view contains a primary key field from the underlying table, visual studio may set unique to true for that field. If your view is constructed in such a way that the field is not unique, then the error will occur. In Visual Studio 2008, open the xsd file, click on the field and set unique to false in properties.</p>
<p>There were other causes of the error but these seemed to be the two most common.</p>
<p>Cheers,<br />
Grant</p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2008/10/microsoft-reporting-failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A better way of handling maxRequestLength exceptions</title>
		<link>http://www.castnerit.com.au/blog/2008/10/a-better-way-of-handling-maxrequestlength-exceptions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-better-way-of-handling-maxrequestlength-exceptions</link>
		<comments>http://www.castnerit.com.au/blog/2008/10/a-better-way-of-handling-maxrequestlength-exceptions/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 01:37:17 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>

		<guid isPermaLink="false">http://castnerit.com/blog/?p=85</guid>
		<description><![CDATA[ASP.NET 2 includes the FileUpload control to make it easier to create pages that allow users to upload files. The default maximum file size is 4096 KB to minimize the potential for denial of service attacks. You can change the maximum file size by editing your configuration files (see for example http://msdn2.microsoft.com/en-US/library/system.web.configuration.httpruntimesection.maxrequestlength(VS.80).aspx and http://support.softartisans.com/kbview_825.aspx). The [...]]]></description>
			<content:encoded><![CDATA[<p>ASP.NET 2 includes the FileUpload control to make it easier to create pages that allow users to upload files. The default maximum file size is 4096 KB to minimize the potential for denial of service attacks. You can change the maximum file size by editing your configuration files (see for example <a href="http://msdn2.microsoft.com/en-US/library/system.web.configuration.httpruntimesection.maxrequestlength(VS.80).aspx">http://msdn2.microsoft.com/en-US/library/system.web.configuration.httpruntimesection.maxrequestlength(VS.80).aspx</a> and <a href="http://support.softartisans.com/kbview_825.aspx">http://support.softartisans.com/kbview_825.aspx</a>).</p>
<p>The problem is that when users attempt to upload a file that is too large, it is difficult to capture and handle the exception that is created. The usual try..catch doesn&#8217;t handle the exception because the exception occurs before then. The exception is &#8220;System.Web.HttpException: Maximum request length exceeded&#8221;. You could of course increase the maximum file size but that defeats the purpose of the limit in the first place.</p>
<p>Here is one solution for handling the exception that is at least nicer than the standard ASP.NET exception message:</p>
<p>1. Create a global.asax file. If you&#8217;re using Visual Studio 2005 it will set up a number of common subroutines for you. You need to use Sub Application_Error. Your code should look something like this:</p>
<p>&lt;script runat=&#8221;server&#8221;&gt;<br />
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)<br />
Dim currentException As Exception<br />
currentException = Server.GetLastError.GetBaseException()<br />
Response.Redirect(&#8220;/error.aspx?Err=&#8221; &amp; Server.UrlEncode(currentException.Message))<br />
End Sub<br />
&lt;/script&gt;</p>
<p>The application_Error sub fires as a last resort, in other words, when you haven&#8217;t explicitly handled the exception anywhere else in your code.</p>
<p>2. You can now create an error.aspx that displays the exception message (from the querystring). For this exception the message is &#8220;<span id="ctl00_ContentPlaceHolder1_lblError">Maximum request length exceeded&#8221;. You could also test for the message and give users more information on the error.</span></p>
<p><span>Please let me know if you have any comments, suggestions, or improvements.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2008/10/a-better-way-of-handling-maxrequestlength-exceptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Formatting columns in a GridView</title>
		<link>http://www.castnerit.com.au/blog/2008/08/formatting-columns-in-a-gridview/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=formatting-columns-in-a-gridview</link>
		<comments>http://www.castnerit.com.au/blog/2008/08/formatting-columns-in-a-gridview/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 15:40:18 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[eLearning]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[Monodroid]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>

		<guid isPermaLink="false">http://castnerit.com/blog/?p=64</guid>
		<description><![CDATA[Formatting columns in a GridView is relatively straightforward, once you know the appropriate format string. Here are the steps if you are using Expression Web, Visual Studio, or Visual Web Developer: Open the Task Pane of your GridView and select Edit Columns In the Selected Fields Box, select the column you want to edit Find [...]]]></description>
			<content:encoded><![CDATA[<p>Formatting columns in a GridView is relatively straightforward, <em>once you know the appropriate format string.</em></p>
<p>Here are the steps if you are using Expression Web, Visual Studio, or Visual Web Developer:</p>
<ol>
<li>Open the Task Pane of your GridView and select <strong>Edit Columns</strong></li>
<li>In the <strong>Selected Fields</strong> Box, select the column you want to edit</li>
<li>Find the <strong>HTMLEncode</strong> property and set it to <strong>false.</strong></li>
<li>Find the <strong>DataFormatString</strong> property and set it to the appropriate formatstring. The standard format of a format string is {0:<em>format string</em>}</li>
</ol>
<p>Some examples of format strings are:</p>
<p>{0:c} to format as currency<br />
{0:M-dd-yyyy} to format as a date</p>
<p>For more formatting strings, go to <a href="http://msdn2.microsoft.com/en-us/library/aa720089(VS.71).aspx">Formatting Types</a> on MSDN.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2008/08/formatting-columns-in-a-gridview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

