<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Mohamed Atia&#039;s Blog</title>
	<atom:link href="http://mohamedatiasblog.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mohamedatiasblog.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Thu, 05 Nov 2009 14:10:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mohamedatiasblog.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Mohamed Atia&#039;s Blog</title>
		<link>http://mohamedatiasblog.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mohamedatiasblog.wordpress.com/osd.xml" title="Mohamed Atia&#039;s Blog" />
	<atom:link rel='hub' href='http://mohamedatiasblog.wordpress.com/?pushpress=hub'/>
		<item>
		<title>A GridView that gets data from LinqDataSource (Part 2)</title>
		<link>http://mohamedatiasblog.wordpress.com/2009/11/05/a-gridview-that-gets-data-from-linqdatasource-part-2/</link>
		<comments>http://mohamedatiasblog.wordpress.com/2009/11/05/a-gridview-that-gets-data-from-linqdatasource-part-2/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 13:55:39 +0000</pubDate>
		<dc:creator>Mohamed Atia's Blog</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[LINQ to SQL]]></category>

		<guid isPermaLink="false">http://mohamedatiasblog.wordpress.com/?p=23</guid>
		<description><![CDATA[Introduction: in this post I will discuss how to create a GridView whose data source is a LinqDataSource. The application will support the following features: -         Paging, editing, deleting, and insertion of a new entry. -         Using some AJAX controls AjaxControlToolkit such as CalenderExtender. -         Validation using RegularExpressionValidator (inside the grid). -         Cleaning up the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mohamedatiasblog.wordpress.com&amp;blog=10221023&amp;post=23&amp;subd=mohamedatiasblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong><em>Introduction</em></strong>: in this post I will discuss how to create a GridView whose data source is a LinqDataSource. The application will support the following features:</p>
<p>-         Paging, editing, deleting, and insertion of a new entry.</p>
<p>-         Using some AJAX controls AjaxControlToolkit such as CalenderExtender.</p>
<p>-         Validation using RegularExpressionValidator (inside the grid).</p>
<p>-         Cleaning up the foreign-key values &amp; replacing them with their values (Binding UI with ASP LinqDataSource).</p>
<p><strong><em>Part 2 Abstract:</em></strong>  you will expect in this part to know about:</p>
<p>-         Cleaning up the foreign-key values &amp; replacing them with their values (Binding UI with ASP LinqDataSource).</p>
<p><strong><em>Note:</em></strong>  If you find that something is ambiguous you might need to refer to the previous parts.</p>
<p>Now we need to replace the foreign-key values in the grid with the actual data i.e. instead of displaying the Employee ID its more user friendly to display the Employee name!!</p>
<p><img class="aligncenter size-full wp-image-24" title="1 whats wrong" src="http://mohamedatiasblog.files.wordpress.com/2009/11/1-whats-wrong.jpg" alt="1 whats wrong" width="548" height="284" /></p>
<p>Let’s think about what shall we do?</p>
<p>If we look at the GridView code it will look like this:</p>
<p><img title="2 PerviewOfGridCode" src="http://mohamedatiasblog.files.wordpress.com/2009/11/2-perviewofgridcode.jpg?w=495&#038;h=202" alt="2 PerviewOfGridCode" width="495" height="202" /></p>
<p>Some BoundFields that are data bound to the columns of the Order table, which I address using LinqDataSource. The solution that I felt better is to replace the BoundFields I don’t wish to display by TemplateFields.</p>
<p>TemplateFields allows me to display the Customer name instead of his ID by evaluating data-binding expression. It also provides a property called EditItemTemplate which is the state of the column in the editing mode (if not set the column can’t be edited).</p>
<p>The TemplateField of the Customer should be as follows:</p>
<p><img class="aligncenter size-full wp-image-26" title="3 templatefieldcus" src="http://mohamedatiasblog.files.wordpress.com/2009/11/3-templatefieldcus.jpg" alt="3 templatefieldcus" width="495" height="79" /><br />
When I replace this code with the Customer TemplateField the Customer name will appear instead of his ID</p>
<p><img class="aligncenter size-full wp-image-35" title="4 CustomerAppears" src="http://mohamedatiasblog.files.wordpress.com/2009/11/4-customerappears1.jpg" alt="4 CustomerAppears" width="495" height="253" /></p>
<p>When I press edit, I will find that I can’t edit it!!</p>
<p><img class="aligncenter size-full wp-image-36" title="5 UneditableCustomer" src="http://mohamedatiasblog.files.wordpress.com/2009/11/5-uneditablecustomer1.jpg" alt="5 UneditableCustomer" width="495" height="155" /></p>
<p>I can’t edit because I didn’t add EditItemTemplate <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Let’s Go and add it now but to prevent users from entering invalid Customer name during the editing mode it is better to display all the customers in a DropDownList while in editing mode, but the DropDownList requires a data source so I created a LinqDataSource called CustomerDataSource.</p>
<p><img class="aligncenter size-full wp-image-37" title="6 CustomersDataSource" src="http://mohamedatiasblog.files.wordpress.com/2009/11/6-customersdatasource1.jpg" alt="6 CustomersDataSource" width="495" height="37" /></p>
<p>If you noticed here I just need the Customers’ name and ID. The Name will act as the DataTextField and the ID will act as the DataValueField in the DropDownList.</p>
<p>Then I will add the EditItemTemplate so the TemplateField I will create a DropDownList that’s DataSourceID is the CustomerDataSource and assign the DataValueField and DataTextField respectively as discussed before, it must look like this:</p>
<p><img class="aligncenter size-full wp-image-38" title="7 EditItemTemplate" src="http://mohamedatiasblog.files.wordpress.com/2009/11/7-edititemtemplate1.png" alt="7 EditItemTemplate" width="495" height="124" /></p>
<p>Now let’s run and see what I’ve done:</p>
<p><img class="aligncenter size-full wp-image-39" title="8 Yay" src="http://mohamedatiasblog.files.wordpress.com/2009/11/8-yay1.jpg" alt="8 Yay" width="495" height="218" /></p>
<p>Then I will do the same to the EmployeeID and ShipVia columns.</p>
<p>That is the end of part 2.</p>
<p>Mohamed Atia<br />
MCTS</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mohamedatiasblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mohamedatiasblog.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mohamedatiasblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mohamedatiasblog.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mohamedatiasblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mohamedatiasblog.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mohamedatiasblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mohamedatiasblog.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mohamedatiasblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mohamedatiasblog.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mohamedatiasblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mohamedatiasblog.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mohamedatiasblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mohamedatiasblog.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mohamedatiasblog.wordpress.com&amp;blog=10221023&amp;post=23&amp;subd=mohamedatiasblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mohamedatiasblog.wordpress.com/2009/11/05/a-gridview-that-gets-data-from-linqdatasource-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8d0a9eb3dd67934b0b5e74a9209b7d7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mohamed Atia's Blog</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/1-whats-wrong.jpg" medium="image">
			<media:title type="html">1 whats wrong</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/2-perviewofgridcode.jpg" medium="image">
			<media:title type="html">2 PerviewOfGridCode</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/3-templatefieldcus.jpg" medium="image">
			<media:title type="html">3 templatefieldcus</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/4-customerappears1.jpg" medium="image">
			<media:title type="html">4 CustomerAppears</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/5-uneditablecustomer1.jpg" medium="image">
			<media:title type="html">5 UneditableCustomer</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/6-customersdatasource1.jpg" medium="image">
			<media:title type="html">6 CustomersDataSource</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/7-edititemtemplate1.png" medium="image">
			<media:title type="html">7 EditItemTemplate</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/8-yay1.jpg" medium="image">
			<media:title type="html">8 Yay</media:title>
		</media:content>
	</item>
		<item>
		<title>A GridView that gets data from LinqDataSource (Part 1)</title>
		<link>http://mohamedatiasblog.wordpress.com/2009/11/01/hello-world/</link>
		<comments>http://mohamedatiasblog.wordpress.com/2009/11/01/hello-world/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 11:28:55 +0000</pubDate>
		<dc:creator>Mohamed Atia's Blog</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[LINQ to SQL]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Introduction: in this post I will discuss how to create a GridView whose data source is a LinqDataSource. The application will support the following features: -         Paging, editing, deleting, and insertion of a new entry. -         Using some AJAX controls AjaxControlToolkit such as CalenderExtender. -         Validation using RegularExpressionValidator (inside the grid). -         Cleaning up the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mohamedatiasblog.wordpress.com&amp;blog=10221023&amp;post=1&amp;subd=mohamedatiasblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong><em>Introduction</em></strong>: in this post I will discuss how to create a GridView whose data source is a LinqDataSource. The application will support the following features:</p>
<p>-         Paging, editing, deleting, and insertion of a new entry.</p>
<p>-         Using some AJAX controls AjaxControlToolkit such as CalenderExtender.</p>
<p>-         Validation using RegularExpressionValidator (inside the grid).</p>
<p>-         Cleaning up the foreign-key values &amp; replacing them with their values (Binding UI with ASP LinqDataSource).</p>
<p><strong><em>Part 1 Abstract:</em></strong>  you will expect in this part to know about:</p>
<p>-         Paging, editing, deleting.</p>
<p><strong><em>Resources</em></strong>: Visual Studio 2008, SQL Server 2005 Express Edition</p>
<p><strong><em>Prerequisites</em></strong>: Readers of this post must have a good knowledge about ASP.Net and LINQ to SQL, I will suppose that you know how to create and use Data Classes our .dbml file should look like this :</p>
<p><img class="aligncenter size-full wp-image-6" title="DBML" src="http://mohamedatiasblog.files.wordpress.com/2009/11/dbml.jpg" alt="DBML" width="496" height="360" /></p>
<p>In this tutorial our data source is Microsoft Northwind Sample database we will show the Orders table in the GridView.</p>
<p><em><strong>Let&#8217;s get started.</strong></em></p>
<p>I just dragged and dropped a GridView from the ToolBox.</p>
<p> <img class="aligncenter size-full wp-image-7" title="Our_Start" src="http://mohamedatiasblog.files.wordpress.com/2009/11/our_start.png" alt="Our_Start" width="497" height="235" /></p>
<p>Step 1: We need to Create a LinqDataSource, this can be done easily using the wizard as follows:</p>
<p><img class="aligncenter size-full wp-image-8" title="step1" src="http://mohamedatiasblog.files.wordpress.com/2009/11/step1.jpg" alt="step1" width="497" height="239" /></p>
<p>Step 2: Select LINQ then press next</p>
<p><img class="aligncenter size-full wp-image-10" title="step2" src="http://mohamedatiasblog.files.wordpress.com/2009/11/step21.jpg" alt="step2" width="497" height="373" /></p>
<p>Step 3: Make Sure that u selected the appropriate Data Classes</p>
<p><img title="step3" src="http://mohamedatiasblog.files.wordpress.com/2009/11/step3.jpg?w=497&#038;h=366" alt="step3" width="497" height="366" /></p>
<p>Step 4: Select thr required table (in our case Orders) and click Advanced</p>
<p><img class="aligncenter size-full wp-image-12" title="step4" src="http://mohamedatiasblog.files.wordpress.com/2009/11/step4.jpg" alt="step4" width="496" height="365" /></p>
<p>Step 5: Make sure that the Check Boxes are checked, this sets the properties of the LinqDataSource which are EnableDelete, EnableInsert, and EnableUpdate to true.</p>
<p><img class="aligncenter size-full wp-image-13" title="step5" src="http://mohamedatiasblog.files.wordpress.com/2009/11/step5.jpg" alt="step5" width="497" height="363" /></p>
<p>Step 6: Make sure that the Grid enables paging, sorting, editing, and deletion. I am not concerned about selection in this article.</p>
<p><img class="aligncenter size-full wp-image-14" title="step6" src="http://mohamedatiasblog.files.wordpress.com/2009/11/step6.jpg" alt="step6" width="497" height="170" /></p>
<p><em><strong>Now let’s run the project and see what we get</strong></em></p>
<p><img class="aligncenter size-full wp-image-15" title="what_have_we_done_1to6_1" src="http://mohamedatiasblog.files.wordpress.com/2009/11/what_have_we_done_1to6_1.jpg" alt="what_have_we_done_1to6_1" width="497" height="388" /></p>
<p>If I click delete, the order will be deleted from the database <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> , if I click update the following will happen:</p>
<p><img class="aligncenter size-full wp-image-16" title="what_have_we_done_1to6_2" src="http://mohamedatiasblog.files.wordpress.com/2009/11/what_have_we_done_1to6_2.jpg" alt="what_have_we_done_1to6_2" width="497" height="216" /></p>
<p>Marvelous and simple!!</p>
<p>Update some values then click update it will reflect in the database.</p>
<p>What I have done is the simple part; I almost used Wizards and UI.</p>
<p>I haven&#8217;t yet completed writing this article but this is the end of this part.</p>
<p>Mohamed Atia<br />
MCTS<span id="_marker"> </span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mohamedatiasblog.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mohamedatiasblog.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mohamedatiasblog.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mohamedatiasblog.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mohamedatiasblog.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mohamedatiasblog.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mohamedatiasblog.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mohamedatiasblog.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mohamedatiasblog.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mohamedatiasblog.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mohamedatiasblog.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mohamedatiasblog.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mohamedatiasblog.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mohamedatiasblog.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mohamedatiasblog.wordpress.com&amp;blog=10221023&amp;post=1&amp;subd=mohamedatiasblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mohamedatiasblog.wordpress.com/2009/11/01/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8d0a9eb3dd67934b0b5e74a9209b7d7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mohamed Atia's Blog</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/dbml.jpg" medium="image">
			<media:title type="html">DBML</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/our_start.png" medium="image">
			<media:title type="html">Our_Start</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/step1.jpg" medium="image">
			<media:title type="html">step1</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/step21.jpg" medium="image">
			<media:title type="html">step2</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/step3.jpg" medium="image">
			<media:title type="html">step3</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/step4.jpg" medium="image">
			<media:title type="html">step4</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/step5.jpg" medium="image">
			<media:title type="html">step5</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/step6.jpg" medium="image">
			<media:title type="html">step6</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/what_have_we_done_1to6_1.jpg" medium="image">
			<media:title type="html">what_have_we_done_1to6_1</media:title>
		</media:content>

		<media:content url="http://mohamedatiasblog.files.wordpress.com/2009/11/what_have_we_done_1to6_2.jpg" medium="image">
			<media:title type="html">what_have_we_done_1to6_2</media:title>
		</media:content>
	</item>
	</channel>
</rss>
