<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-36836321</id><updated>2012-02-16T04:22:49.602-08:00</updated><category term='Tracker(User Info)'/><category term='DataGrid'/><category term='Master Pages'/><category term='Visual Source Safe'/><category term='Wen Parts'/><category term='DataList'/><category term='Caching'/><category term='Stored Procedure'/><category term='Global.asax'/><category term='GridView'/><title type='text'>dotnet</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cdotnet.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://cdotnet.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>narayana</name><uri>http://www.blogger.com/profile/01832239949875659847</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-36836321.post-3831727321710728065</id><published>2008-03-11T05:57:00.000-07:00</published><updated>2008-03-11T05:59:57.240-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tracker(User Info)'/><title type='text'>How to track visitors to your site in ASP.NET &amp; C#  - 2</title><content type='html'>&lt;span style="color:#ff6666;"&gt;Code to log the IP address &amp;amp; DNS name for visitors to each page&lt;/span&gt;&lt;br /&gt;Once you have published a site in ASP.NET, you'd like to know who are your visitors. One way is to check your event log on the host server. Another option is to write your own code. You'd basically like to log the IP address, and DNS name for the visitor, and it would be nice to know which page they are visiting.&lt;br /&gt;To log the ip address using ASP.NET, you can call:&lt;br /&gt;Request.ServerVariables["HTTP_X_FORWARDED_FOR"]&lt;br /&gt;Another usefull variable is&lt;br /&gt;Request.ServerVariables["REMOTE_ADDR"]&lt;br /&gt;A combination of the two can be done as follows:&lt;br /&gt;private string IpAddress()&lt;br /&gt;{&lt;br /&gt;string strIpAddress;&lt;br /&gt;strIpAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];&lt;br /&gt;if (strIpAddress == null)&lt;br /&gt;{&lt;br /&gt;strIpAddress = Request.ServerVariables["REMOTE_ADDR"];&lt;br /&gt;}&lt;br /&gt;return strIpAddress;&lt;br /&gt;}&lt;br /&gt;Next, you'd want to log the DNS name. To do so, you can call:&lt;br /&gt;Dns.GetHostByAddress(string ipAddress)&lt;br /&gt;And log the HostName property returned by the call. Now to log the address of the page being requested, you can call:&lt;br /&gt;Request.Url.ToString()&lt;br /&gt;So to combine all these together, here is the code to build a visitors.log file:&lt;br /&gt;// Track Visitors&lt;br /&gt;string ipAddress = IpAddress();&lt;br /&gt;string hostName = Dns.GetHostByAddress(ipAddress).HostName;&lt;br /&gt;StreamWriter wrtr = new StreamWriter(Server.MapPath("visitors.log"), true);&lt;br /&gt;wrtr.WriteLine(DateTime.Now.ToString() + "  " + ipAddress + "  " + hostName + "  " + Request.Url.ToString());&lt;br /&gt;wrtr.Close();&lt;br /&gt;The next question is what part of your ASP.NET page can you put the above code? There are two possible places, the first would be in the Application.BeginRequest event handler, the second can be in the Master page Load event. Here is how to do it in the Load event:&lt;br /&gt;using System;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Net;&lt;br /&gt;using System.IO;&lt;br /&gt;namespace MyWebSite&lt;br /&gt;{&lt;br /&gt;public partial class DefaultMasterPage : System.Web.UI.MasterPage&lt;br /&gt;{&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;// Track Visitors&lt;br /&gt;string ipAddress = IpAddress();&lt;br /&gt;string hostName = Dns.GetHostByAddres(ipAddress).HostName;&lt;br /&gt;StreamWriter wrtr = new StreamWriter(Server.MapPath("visitors.log"), true);&lt;br /&gt;wrtr.WriteLine(DateTime.Now.ToString() + "  " + ipAddress + "  " + hostName + "  " + Request.Url.ToString());&lt;br /&gt;wrtr.Close();&lt;br /&gt;}&lt;br /&gt;private string IpAddress()&lt;br /&gt;{&lt;br /&gt;string strIpAddress;&lt;br /&gt;strIpAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];&lt;br /&gt;if (strIpAddress == null)&lt;br /&gt;{&lt;br /&gt;strIpAddress = Request.ServerVariables["REMOTE_ADDR"];&lt;br /&gt;}&lt;br /&gt;return strIpAddress;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;Once you start getting some visitors, the result visitors.log file would look something like this:&lt;br /&gt;4/2/2007 8:47:34 PM  74.6.67.155  lj612164.inktomisearch.com  &lt;a href="http://www.mycsharpcorner.com/Post.aspx?postID=22"&gt;http://www.mycsharpcorner.com/Post.aspx?postID=22&lt;/a&gt;&lt;br /&gt;4/2/2007 8:53:05 PM  66.249.66.35  crawl-66-249-66-35.googlebot.com  &lt;a href="http://www.mycsharpcorner.com/Default.aspx?categoryID=18"&gt;http://www.mycsharpcorner.com/Default.aspx?categoryID=18&lt;/a&gt;&lt;br /&gt;4/2/2007 9:02:41 PM  66.249.66.35  crawl-66-249-66-35.googlebot.com  &lt;a href="http://www.mycsharpcorner.com/Default.aspx"&gt;http://www.mycsharpcorner.com/Default.aspx&lt;/a&gt;&lt;br /&gt;4/2/2007 10:06:20 PM  69.117.147.109  ool-4575936d.dyn.optonline.net  &lt;a href="http://www.mycsharpcorner.com/Post.aspx?postID=15"&gt;http://www.mycsharpcorner.com/Post.aspx?postID=15&lt;/a&gt;&lt;br /&gt;4/2/2007 10:12:23 PM  72.30.216.102  lm502014.inktomisearch.com  &lt;a href="http://www.mycsharpcorner.com/Post.aspx?postID=22"&gt;http://www.mycsharpcorner.com/Post.aspx?postID=22&lt;/a&gt;&lt;br /&gt;4/2/2007 11:04:24 PM  66.249.66.35  crawl-66-249-66-35.googlebot.com  &lt;a href="http://www.mycsharpcorner.com/Post.aspx?postID=15"&gt;http://www.mycsharpcorner.com/Post.aspx?postID=15&lt;/a&gt;&lt;br /&gt;4/2/2007 11:08:22 PM  66.249.66.35  crawl-66-249-66-35.googlebot.com  &lt;a href="http://www.mycsharpcorner.com/Post.aspx?postID=23"&gt;http://www.mycsharpcorner.com/Post.aspx?postID=23&lt;/a&gt;&lt;br /&gt;Happy Programming!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36836321-3831727321710728065?l=cdotnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cdotnet.blogspot.com/feeds/3831727321710728065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=36836321&amp;postID=3831727321710728065' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/3831727321710728065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/3831727321710728065'/><link rel='alternate' type='text/html' href='http://cdotnet.blogspot.com/2008/03/how-to-track-visitors-to-your-site-in_11.html' title='How to track visitors to your site in ASP.NET &amp; C#  - 2'/><author><name>narayana</name><uri>http://www.blogger.com/profile/01832239949875659847</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36836321.post-8938243075570101563</id><published>2008-03-11T05:54:00.000-07:00</published><updated>2008-03-11T05:57:06.528-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tracker(User Info)'/><title type='text'>How to track visitors to your site in ASP.NET &amp; C#</title><content type='html'>Once you have published a site in ASP.NET, you'd like to know who are your visitors. One way is to check your event log on the host server. Another option is to write your own code. You'd basically like to log the IP address, and DNS name for the visitor, and it would be nice to know which page they are visiting.&lt;br /&gt;To log the ip address using ASP.NET, you can call:&lt;br /&gt;Request.ServerVariables["HTTP_X_FORWARDED_FOR"]&lt;br /&gt;Another usefull variable is&lt;br /&gt;Request.ServerVariables["REMOTE_ADDR"]&lt;br /&gt;A combination of the two can be done as follows:&lt;br /&gt;private string IpAddress()&lt;br /&gt;{&lt;br /&gt;    string strIpAddress;&lt;br /&gt;    strIpAddress =&lt;br /&gt;       Request.ServerVariables ["HTTP_X_FORWARDED_FOR"];&lt;br /&gt;    if (strIpAddress == null)&lt;br /&gt;        strIpAddress = Request.ServerVariables["REMOTE_ADDR"];&lt;br /&gt;    return strIpAddress;&lt;br /&gt;}&lt;br /&gt;Next, you'd want to log the DNS name. To do so, you can call:&lt;br /&gt;Dns .GetHostByAddress( string ipAddress);&lt;br /&gt;And log the HostName property returned by the call. Now to log the address of the page being requested, you can call:&lt;br /&gt;Request.Url.ToString();&lt;br /&gt;So to combine all these together, here is the code to build a visitors.log file:&lt;br /&gt;// Track Visitors&lt;br /&gt;string ipAddress = IpAddress();&lt;br /&gt;string hostName = Dns .GetHostByAddress(ipAddress).HostName;&lt;br /&gt;StreamWriter wrtr = new StreamWriter( Server.MapPath(&lt;br /&gt;   "visitors.log" ), true );&lt;br /&gt;wrtr.WriteLine( DateTime .Now.ToString() + "  " + ipAddress&lt;br /&gt;   + "  " + hostName + "  " + Request.Url.ToString());&lt;br /&gt;wrtr.Close();&lt;br /&gt;The next question is what part of your ASP.NET page can you put the above code? There are two possible places, the first would be in the Application.BeginRequest event handler, the second can be in the Master page Load event. Here is how to do it in the Load event:&lt;br /&gt;using System;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Net;&lt;br /&gt;using System.IO;&lt;br /&gt; &lt;br /&gt;namespace MyWebSite&lt;br /&gt;{&lt;br /&gt;    public partial class DefaultMasterPage : System.Web.UI.MasterPage&lt;br /&gt;    {&lt;br /&gt;        protected void Page_Load( object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Track Visitors&lt;br /&gt;            string ipAddress = IpAddress();&lt;br /&gt;            string hostName = Dns .GetHostByAddres(ipAddress).HostName;&lt;br /&gt;            StreamWriter wrtr = new StreamWriter (Server.MapPath( "visitors.log" ), true );&lt;br /&gt;            wrtr.WriteLine( DateTime .Now.ToString() + "  " + ipAddress + "  " + hostName + "  " + Request.Url.ToString());&lt;br /&gt;            wrtr.Close();&lt;br /&gt;        }&lt;br /&gt;        private string IpAddress()&lt;br /&gt;        {&lt;br /&gt;            string strIpAddress;&lt;br /&gt;            strIpAddress = Request.ServerVariables[ "HTTP_X_FORWARDED_FOR" ];&lt;br /&gt;            if (strIpAddress == null )&lt;br /&gt;                strIpAddress = Request.ServerVariables[ "REMOTE_ADDR" ];&lt;br /&gt;            return strIpAddress;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;Once you start getting some visitors, the result visitors.log file would look something like this:4/2/20078:47:34 PM  74.6.67.155  lj612164.inktomisearch.com  &lt;a href="http://www.mycsharpcorner.com/Post.aspx?postID=22"&gt;http://www.mycsharpcorner.com/Post.aspx?postID=22&lt;/a&gt;&lt;br /&gt;4/2/20078:53:05 PM  66.249.66.35  crawl-66-249-66-35.googlebot.com  &lt;a href="http://www.mycsharpcorner.com/Default.aspx?categoryID=18"&gt;http://www.mycsharpcorner.com/Default.aspx?categoryID=18&lt;/a&gt;&lt;br /&gt;4/2/20079:02:41 PM  66.249.66.35  crawl-66-249-66-35.googlebot.com  &lt;a href="http://www.mycsharpcorner.com/Default.aspx"&gt;http://www.mycsharpcorner.com/Default.aspx&lt;/a&gt;&lt;br /&gt;4/2/200710:06:20 PM  69.117.147.109  ool-4575936d.dyn.optonline.net  &lt;a href="http://www.mycsharpcorner.com/Post.aspx?postID=15"&gt;http://www.mycsharpcorner.com/Post.aspx?postID=15&lt;/a&gt;&lt;br /&gt;4/2/200710:12:23 PM  72.30.216.102  lm502014.inktomisearch.com  &lt;a href="http://www.mycsharpcorner.com/Post.aspx?postID=22"&gt;http://www.mycsharpcorner.com/Post.aspx?postID=22&lt;/a&gt;&lt;br /&gt;4/2/200711:04:24 PM  66.249.66.35  crawl-66-249-66-35.googlebot.com  &lt;a href="http://www.mycsharpcorner.com/Post.aspx?postID=15"&gt;http://www.mycsharpcorner.com/Post.aspx?postID=15&lt;/a&gt;&lt;br /&gt;4/2/200711:08:22 PM  66.249.66.35  crawl-66-249-66-35.googlebot.com  &lt;a href="http://www.mycsharpcorner.com/Post.aspx?postID=23"&gt;http://www.mycsharpcorner.com/Post.aspx?postID=23&lt;/a&gt;&lt;br /&gt;And now you can know who comes to visit your ASP.NET Page.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36836321-8938243075570101563?l=cdotnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cdotnet.blogspot.com/feeds/8938243075570101563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=36836321&amp;postID=8938243075570101563' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/8938243075570101563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/8938243075570101563'/><link rel='alternate' type='text/html' href='http://cdotnet.blogspot.com/2008/03/how-to-track-visitors-to-your-site-in.html' title='How to track visitors to your site in ASP.NET &amp; C#'/><author><name>narayana</name><uri>http://www.blogger.com/profile/01832239949875659847</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36836321.post-7456517237321484102</id><published>2008-01-28T21:38:00.000-08:00</published><updated>2008-01-28T21:53:02.411-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Wen Parts'/><title type='text'>Use ASP.NET 2.0 Web Parts and Membership stuff with SQL Server 2000</title><content type='html'>&lt;div&gt;By default ASP.NET 2.0 Web Parts uses SQL Express. To use this stuff with SQL Server 2000 you must configure the aspnetdb database on your SQL Server 2000 database server. Fortunately for us, Microsoft has created a utility to automate the process. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;&lt;strong&gt;Follow these steps to setup the aspnetdb database:&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;run the utility - C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\aspnet_regsql.exe (this was written with ASP.NET 2.0 Beta 2 (v2.0.50215) as a reference, so with the final release of .NET 2.0 the version number will be different.)&lt;/div&gt;&lt;ol&gt;&lt;li&gt;Select the “Configure SQL Server for application services” option and click “Next”.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Enter your server name, login credentials and the name of the database to create/edit with the aspnetdb stuff.(The database will hold your login and personalization data, so if you don't have complete control over the database server (if you use a remote hosting service like I do) you will want to point this utility to the database you are going to use for your web site. You know, keep all your sites data in the same database. This is the same database that the Membership Provider uses to store user credentials.)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Add the following stuff to your web sites Web.config file (this stuff tells ASP.NET to use your SQL Server 2000 database instead of SQL Express):&lt;/li&gt;&lt;/ol&gt;&lt;a href="http://bp0.blogger.com/_jU-AORtFHik/R56_B2JZ-6I/AAAAAAAAAE0/of5rlk01dE0/s1600-h/webparts+config+for+sqlserver2000.bmp"&gt;&lt;img id="BLOGGER_PHOTO_ID_5160772261448907682" style="CURSOR: hand" alt="" src="http://bp0.blogger.com/_jU-AORtFHik/R56_B2JZ-6I/AAAAAAAAAE0/of5rlk01dE0/s400/webparts+config+for+sqlserver2000.bmp" border="0" /&gt;&lt;/a&gt;&lt;a href="http://bp3.blogger.com/_jU-AORtFHik/R56_BmJZ-5I/AAAAAAAAAEs/ySwrjIRP-ds/s1600-h/code+for+web+config.bmp"&gt; &lt;img id="BLOGGER_PHOTO_ID_5160772257153940370" style="CURSOR: hand" alt="" src="http://bp3.blogger.com/_jU-AORtFHik/R56_BmJZ-5I/AAAAAAAAAEs/ySwrjIRP-ds/s400/code+for+web+config.bmp" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36836321-7456517237321484102?l=cdotnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cdotnet.blogspot.com/feeds/7456517237321484102/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=36836321&amp;postID=7456517237321484102' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/7456517237321484102'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/7456517237321484102'/><link rel='alternate' type='text/html' href='http://cdotnet.blogspot.com/2008/01/use-aspnet-20-web-parts-and-membership.html' title='Use ASP.NET 2.0 Web Parts and Membership stuff with SQL Server 2000'/><author><name>narayana</name><uri>http://www.blogger.com/profile/01832239949875659847</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp0.blogger.com/_jU-AORtFHik/R56_B2JZ-6I/AAAAAAAAAE0/of5rlk01dE0/s72-c/webparts+config+for+sqlserver2000.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36836321.post-2915074226603667251</id><published>2008-01-25T00:00:00.000-08:00</published><updated>2008-01-27T22:12:04.975-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual Source Safe'/><title type='text'>Integrated Development Environment (IDE) Integration</title><content type='html'>Microsoft® Visual SourceSafe™ version control software provides integration with the Microsoft Visual Basic® (Enterprise and Professional editions) programming system and with the Microsoft Developer Studio®, so you can enjoy the advantages of source code control—team coordination and version tracking—without having to leave your IDE.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Visual SourceSafe and Visual Basic&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Visual Basic is rapidly moving from being a simple stand-alone development tool to being a powerful client-server corporate application development environment. New needs come with that growth: the need to coordinate large teams of programmers working together and the need to track Visual Basic code like any other mission-critical data that runs a company, in short, the need for version control.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;At the same time, Visual Basic has built its reputation around an interface which is easy to learn and easy to use. If version control adds a new burden to developers, many of them simply will not use it and there will be no benefits at all! That's why checking forms in and out of Visual SourceSafe has to be just as easy as modifying those forms in Visual Basic. And that's why Visual SourceSafe 4.0 integrates directly into the Visual Basic IDE.&lt;br /&gt;&lt;a href="http://bp0.blogger.com/_jU-AORtFHik/R5mXZGJZ-2I/AAAAAAAAAEU/kfILVg21iDM/s1600-h/Bb509335.ide1(en-US,VS.80).gif"&gt;&lt;img id="BLOGGER_PHOTO_ID_5159321305532201826" style="CURSOR: hand" alt="" src="http://bp0.blogger.com/_jU-AORtFHik/R5mXZGJZ-2I/AAAAAAAAAEU/kfILVg21iDM/s400/Bb509335.ide1(en-US,VS.80).gif" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;Figure 1. SourceSafe integrated into Visual Basic&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Without leaving Visual Basic, you can check a form out, modify that form, and check it back in. Without ever looking at the Visual SourceSafe Explorer, you can view the changes you made to a form, the history of a basic module, or even see a list of all the projects that are sharing a VISUAL BASIC class. And if you check out a .FRM file, the .FRX file "tags along" automatically, so just as always, you don't need to worry about it.&lt;br /&gt;&lt;br /&gt;Of course, the Visual SourceSafe Explorer is still available for advanced features such as branching and merging. But most users will never have to leave Visual Basic to enjoy all the benefits of coordinated team development and version tracking.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Visual SourceSafe and Microsoft Developer Studio&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Microsoft Developer Studio is the new IDE that combines award-winning products such as Visual C++®, Visual Test, and Microsoft Fortran PowerStation. Users of these products not only enjoy the fastest path to Windows® development, powerful automated testing, and Microsoft technical information—they also have the benefit of using all these products inside one integrated shell. And now, with Visual SourceSafe 4.0, the ability to check your source files in and out is literally "at your fingertips" in the same common shell!&lt;br /&gt;&lt;a href="http://bp1.blogger.com/_jU-AORtFHik/R5mXZWJZ-3I/AAAAAAAAAEc/EUbEdcY3fJk/s1600-h/Bb509335.ide2(en-US,VS.80).gif"&gt;&lt;img id="BLOGGER_PHOTO_ID_5159321309827169138" style="CURSOR: hand" alt="" src="http://bp1.blogger.com/_jU-AORtFHik/R5mXZWJZ-3I/AAAAAAAAAEc/EUbEdcY3fJk/s400/Bb509335.ide2(en-US,VS.80).gif" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;Figure 2. Visual SourceSafe integrated into the Developer Studio&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As an example, imagine running the Visual C++ debugger to track down a problem reported by a tester or customer. You pull down the Tools menu, choose Get from SourceControl, and get all the files in the project, just to make sure you are up-to-date with everyone's changes. Then you debug and find the problem. You right-click on the file and choose Check Out to tell Visual SourceSafe you will be making changes. You edit the file, fix the problem, and use the right mouse button again to choose Check In and publish your changes for the rest of the group.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;But why was this problem not caught? Switching to Microsoft Visual Test, you use the Visual SourceSafe Get command again to get the test scripts, and discover a missing test case. So you create the new test case and add it to Visual SourceSafe, along with a comment explaining the bug that this test will trap. During this entire session, you have not left the Developer Studio window.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Visual SourceSafe 4.0 integrates with the Developer Studio and with Visual Basic 4.0 Professional and Enterprise editions. Visual SourceSafe is not a part of most of these products (it is a part of Visual Basic Enterprise Edition), and must be acquired separately. Visual SourceSafe can also be used with many other development environments, including (but not limited to) the Microsoft Visual FoxPro® database management system and Microsoft Office, by performing all Visual SourceSafe commands directly in the Visual SourceSafe Explorer.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Visual SourceSafe and Visual FoxPro&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Microsoft FoxPro has long been recognized as the fastest, most powerful database development tool. With Visual FoxPro 3.0 developers could tap into the versatility of Object Oriented programming and client-server functionality. Now Visual FoxPro 5.0 adds yet another dimension that developers have requested—team based application development.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With just a few mouse clicks, a developer can join a multideveloper project and from then on, all changes, whether they add files to the project or modify existing files, can be coordinated from within the Visual FoxPro IDE.&lt;br /&gt;&lt;a href="http://bp3.blogger.com/_jU-AORtFHik/R5mXZ2JZ-4I/AAAAAAAAAEk/tvUns7KD-nE/s1600-h/Bb509335.ide3(en-US,VS.80).gif"&gt;&lt;img id="BLOGGER_PHOTO_ID_5159321318417103746" style="CURSOR: hand" alt="" src="http://bp3.blogger.com/_jU-AORtFHik/R5mXZ2JZ-4I/AAAAAAAAAEk/tvUns7KD-nE/s400/Bb509335.ide3(en-US,VS.80).gif" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;Figure 3. Visual SourceSafe integrated into Visual FoxPro&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In a team environment, having a project—a .PJX in FoxPro terminology—under SourceSafe control means that:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;All developers on the team can add files to, or remove them from, the PJX. By choosing Update Project List from the project menu, a developer both makes any changes he or she has made to the PJX available to all the other developers on the team and receives an updated version of the project, reflecting changes other developers have made.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Two or more developers can work on the same program (PRG) simultaneously. If, for example, two developers have checked out the same program, and both have modified it, unaware of each other's changes, Visual SourceSafe will alert the one who checks in the program last, prompting him or her to resolve any conflicts between the different versions.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Of course team development is just one of the many uses of SourceSafe integration. If you are an individual developer you will want to take advantage of other features including:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Maintaining a history of files, so you can compare the current version of a file with previous versions.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Labeling Projects enables you to take a snapshot of a project at a given stage in the development cycle and give it a meaningful name (foe example, "Beta 1") before you continue development&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Sharing files means that if you have a file containing commonly used routines that you include in multiple projects (typically known as a library or procedure file), changes made in any copy of that file are automatically propagated to all other copies.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36836321-2915074226603667251?l=cdotnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cdotnet.blogspot.com/feeds/2915074226603667251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=36836321&amp;postID=2915074226603667251' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/2915074226603667251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/2915074226603667251'/><link rel='alternate' type='text/html' href='http://cdotnet.blogspot.com/2008/01/integrated-development-environment-ide.html' title='Integrated Development Environment (IDE) Integration'/><author><name>narayana</name><uri>http://www.blogger.com/profile/01832239949875659847</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp0.blogger.com/_jU-AORtFHik/R5mXZGJZ-2I/AAAAAAAAAEU/kfILVg21iDM/s72-c/Bb509335.ide1(en-US,VS.80).gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36836321.post-6561040347509124979</id><published>2008-01-21T22:49:00.000-08:00</published><updated>2008-01-21T22:52:12.030-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Stored Procedure'/><title type='text'>Calling a stored procedure from ASP.Net</title><content type='html'>&lt;strong&gt;Calling a stored procedure from &lt;/strong&gt;&lt;a class="kLink" oncontextmenu="return false;" id="KonaLink0" onmouseover="adlinkMouseOver(event,this,0);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,0);" onmouseout="adlinkMouseOut(event,this,0);" href="http://www.wwwcoder.com/main/parentid/255/site/5014/68/default.aspx#" target="_top"&gt;&lt;strong&gt;ASP&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.Net&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;With ASP.Net 2.0 available now, I wanted to create an ASP.Net page that would pass parameters to a SQL Server stored procedure to insert data into a &lt;a class="kLink" oncontextmenu="return false;" id="KonaLink1" onmouseover="adlinkMouseOver(event,this,1);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,1);" onmouseout="adlinkMouseOut(event,this,1);" href="http://www.wwwcoder.com/main/parentid/255/site/5014/68/default.aspx#" target="_top"&gt;database&lt;/a&gt;. I've read that this can be done now with controls and almost no understanding of coding, but I wanted to do it manually. It surprised me that I couldn't find a decent online sample from &lt;a class="kLink" oncontextmenu="return false;" id="KonaLink2" onmouseover="adlinkMouseOver(event,this,2);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,2);" onmouseout="adlinkMouseOut(event,this,2);" href="http://www.wwwcoder.com/main/parentid/255/site/5014/68/default.aspx#" target="_top"&gt;Google&lt;/a&gt;, which motivated me to put together this short article.&lt;br /&gt;&lt;br /&gt;I guess I'm from the "old school" because I learned coding without a fancy GUI and I still have a tendency to lean that direction when possible. The latest version of &lt;a class="kLink" oncontextmenu="return false;" id="KonaLink3" onmouseover="adlinkMouseOver(event,this,3);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,3);" onmouseout="adlinkMouseOut(event,this,3);" href="http://www.wwwcoder.com/main/parentid/255/site/5014/68/default.aspx#" target="_top"&gt;Visual Studio&lt;/a&gt; is a great tool, but I still like to understand what's going on rather than just dragging and dropping controls onto a page. Perhaps with some more time I'll give up on this way of thinking, but for now I still like to hand-code at times.&lt;br /&gt;&lt;br /&gt;With ASP.Net 2.0 available now, I wanted to create an ASP.&lt;a class="kLink" oncontextmenu="return false;" id="KonaLink4" onmouseover="adlinkMouseOver(event,this,4);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,4);" onmouseout="adlinkMouseOut(event,this,4);" href="http://www.wwwcoder.com/main/parentid/255/site/5014/68/default.aspx#" target="_top"&gt;Net page&lt;/a&gt; that would pass parameters to a SQL Server stored procedure to insert data into a database. I've read that this can be done now with controls and almost no understanding of coding, but I wanted to do it manually. It surprised me that I couldn't find a decent online sample from Google, which motivated me to put together this short article.&lt;br /&gt;&lt;br /&gt;I am using Visual Studio 2005 to create my &lt;a class="kLink" oncontextmenu="return false;" id="KonaLink5" onmouseover="adlinkMouseOver(event,this,5);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,5);" onmouseout="adlinkMouseOut(event,this,5);" href="http://www.wwwcoder.com/main/parentid/255/site/5014/68/default.aspx#" target="_top"&gt;test page&lt;/a&gt;. I set up a page with nothing more than a submit button and then started adding code to the submit function in the associated .vb code file.&lt;br /&gt;The first thing I had to do was add "Imports &lt;a class="kLink" oncontextmenu="return false;" id="KonaLink6" onmouseover="adlinkMouseOver(event,this,6);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,6);" onmouseout="adlinkMouseOut(event,this,6);" href="http://www.wwwcoder.com/main/parentid/255/site/5014/68/default.aspx#" target="_top"&gt;System&lt;/a&gt;.Data.SqlClient" to the very top of the file. Without that the data objects weren't being recognized.&lt;br /&gt;&lt;br /&gt;After that imports statement is added, the rest isn't too complex.&lt;br /&gt;&lt;br /&gt;I created a variable to hold my connection string represented by below (put your real connection string here). I then created a &lt;a class="kLink" oncontextmenu="return false;" id="KonaLink7" onmouseover="adlinkMouseOver(event,this,7);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,7);" onmouseout="adlinkMouseOut(event,this,7);" href="http://www.wwwcoder.com/main/parentid/255/site/5014/68/default.aspx#" target="_top"&gt;SQL&lt;/a&gt; connection based on the connection string, and also created a SQL Command based on that SQL Connection. When creating the SQL Command you need to pass the name of the &lt;a class="kLink" oncontextmenu="return false;" id="KonaLink8" onmouseover="adlinkMouseOver(event,this,8);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,8);" onmouseout="adlinkMouseOut(event,this,8);" href="http://www.wwwcoder.com/main/parentid/255/site/5014/68/default.aspx#" target="_top"&gt;stored procedure&lt;/a&gt; ("Insert_Test" in this case) and the name of the connection object.&lt;br /&gt;&lt;br /&gt;The next thing you need to do is tell the command that it is going to be calling a stored procedure. You do this by setting the Command Type to Data.CommandType.StoredProcedure (VS's intellisense makes it really easy to find what you need if you don't remember exactly what you need to type).&lt;br /&gt;&lt;br /&gt;Next I added a parameter to the SQL Command object providing the name of the parameter and also the &lt;a class="kLink" oncontextmenu="return false;" id="KonaLink9" onmouseover="adlinkMouseOver(event,this,9);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,9);" onmouseout="adlinkMouseOut(event,this,9);" href="http://www.wwwcoder.com/main/parentid/255/site/5014/68/default.aspx#" target="_top"&gt;data type&lt;/a&gt; and size. After the parameter is added the value needs to be specified. Until you specify the value, no data is actually set, so be sure to perform this step. In this sample I'm only sending one parameter value but I could have just as easily sent 20 if needed.&lt;br /&gt;Lastly I open the connection, execute the stored procedure (automatically passing the parameters defined), and close the connection.&lt;br /&gt;&lt;br /&gt;Here is the entire subroutine with the code I used:&lt;br /&gt;&lt;br /&gt;Protected Sub Btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn1.Click&lt;br /&gt;Dim sConnStr As String = {MyConnectionString}&lt;br /&gt;Dim cnBKTest As New SqlConnection(sConnStr)&lt;br /&gt;Dim cmdTest As New SqlCommand("Insert_Test", cnBKTest)&lt;br /&gt;cmdTest.CommandType = Data.CommandType.StoredProcedure&lt;br /&gt;cmdTest.Parameters.Add(New SqlParameter("@TestParam", Data.SqlDbType.VarChar, 10))&lt;br /&gt;cmdTest.Parameters("@TestParam").Value = "Testing"&lt;br /&gt;cnBKTest.Open()&lt;br /&gt;cmdTest.ExecuteNonQuery()&lt;br /&gt;cnBKTest.Close()&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;That's it! It really isn't very hard, but since I couldn't find an online sample I wound up fussing with this for about an hour. Hopefully this will give someone else a good start and save them from wasting time scratching their heads like I did.&lt;br /&gt;~Brad&lt;br /&gt;Brad Kingsley is founder and president of &lt;a style="COLOR: rgb(82,56,165)" href="http://www.orcsweb.com/" fokim="1" kt01g="0"&gt;ORCS Web, Inc.&lt;/a&gt; - a company that provides managed hosting services for clients who develop and deploy their &lt;a class="kLink" oncontextmenu="return false;" id="KonaLink10" onmouseover="adlinkMouseOver(event,this,10);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,10);" onmouseout="adlinkMouseOut(event,this,10);" href="http://www.wwwcoder.com/main/parentid/255/site/5014/68/default.aspx#" target="_top"&gt;applications&lt;/a&gt; on Microsoft Windows platforms.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36836321-6561040347509124979?l=cdotnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cdotnet.blogspot.com/feeds/6561040347509124979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=36836321&amp;postID=6561040347509124979' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/6561040347509124979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/6561040347509124979'/><link rel='alternate' type='text/html' href='http://cdotnet.blogspot.com/2008/01/calling-stored-procedure-from-aspnet.html' title='Calling a stored procedure from ASP.Net'/><author><name>narayana</name><uri>http://www.blogger.com/profile/01832239949875659847</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36836321.post-7667155952717738602</id><published>2008-01-01T21:01:00.000-08:00</published><updated>2008-01-01T21:17:13.440-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DataGrid'/><title type='text'>ASP.NET Popup Dialog - Confirm Delete - Javascript - DataGrid Example</title><content type='html'>Awhile back I wrote a post called ASP.NET Popup Dialog - Confirm Delete - Javascript.&lt;br /&gt;The example was pretty simple, but it did not cover how to handle the situation in the case of a datagrid, and I have had numerous requests for an example using a datagrid. Personally, I don't use DataGrids that much, because I prefer the unlimited flexibility I get from a DataReader or DataList, but below is a very simple and quick example I created this morning to help those who sent me a request.&lt;br /&gt;I used in-line coding (by hand - no intellisense ;) for the example to make it simple to follow and cut-and-paste, but in my daily work I always use code-behind (Note that in-line coding may make a comback in ASP.NET 2.0 - good or bad). The example just binds 3 contacts via an ArrayList to a datagrid. Although the datagrid has a “ButtonColumn“ that you could use for firing the “delete“ command, I like using images, so I went ahead and just made a template column with an ImageButton.&lt;br /&gt;The main pieces here are the ItemCreated and ItemCommand events fired by the DataGrid. When the DataGrid is creating the items, we find the Delete Button (btnDelete) in the item and attach the onclick event to it to invoke the popup dialog. When an event is fired within the DataGrid (clicking of the btnDelete Image Button), the ItemCommand event fires (only if you choose OK from the confirm delete dialog) and calls the DeleteContact_Click handler which does a real quick and dirty delete of the contact using the ItemIndex (note this is a hack just to show you how it works).&lt;br /&gt;I tested the code and it works fine. Here is the online example. Again, this is only 1 way you could pull this off and I did this quick and dirty just to show an example similar to the previous article. I hope it helps those who sent me requests...&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:arial;font-size:180%;color:#cc0000;"&gt;For Code &lt;/span&gt;&lt;/strong&gt;&lt;a href="http://lakshminarayana.goud.googlepages.com/DatagridDelete.doc"&gt;&lt;strong&gt;&lt;span style="font-family:arial;font-size:180%;color:#cc0000;"&gt;Click Here to Download:&lt;/span&gt;&lt;/strong&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36836321-7667155952717738602?l=cdotnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cdotnet.blogspot.com/feeds/7667155952717738602/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=36836321&amp;postID=7667155952717738602' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/7667155952717738602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/7667155952717738602'/><link rel='alternate' type='text/html' href='http://cdotnet.blogspot.com/2008/01/aspnet-popup-dialog-confirm-delete.html' title='ASP.NET Popup Dialog - Confirm Delete - Javascript - DataGrid Example'/><author><name>narayana</name><uri>http://www.blogger.com/profile/01832239949875659847</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36836321.post-2372805635452422586</id><published>2007-12-19T02:31:00.001-08:00</published><updated>2007-12-20T00:27:26.697-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Master Pages'/><title type='text'>Ground Up : Master Pages in ASP.NET 2.0</title><content type='html'>&lt;strong&gt;&lt;span style="font-size:180%;"&gt;Introduction:&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Master pages are a new cool feature that has been added to the Asp.net 2.0, known as "Whidbey". A Web application has to look consistent and for that every page must be like the every other page. In Asp.net 1.1 we used Cascading Style Sheets to make a common template for all the pages and than we simply copy and paste the html source of one page to the other to make it consistent.&lt;br /&gt;Asp.net 2.0 introduces master pages that are used to make the pages of the website consistent. In this article we will see how to set up master pages and how we can use master pages in our .aspx pages.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Adding a Master page (Sample1.master):&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Adding a master page to your web application is straight forward. Just right click on the project and select "Add New Item" and than select "Master Page". This will add the master page to your project. Now if you see your master page in the design window you will see something like this: &lt;a href="http://bp0.blogger.com/_jU-AORtFHik/R2jzNRMhlmI/AAAAAAAAACw/tOqcT-ciy8E/s1600-h/masterpages_image1.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5145629983550576226" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://bp0.blogger.com/_jU-AORtFHik/R2jzNRMhlmI/AAAAAAAAACw/tOqcT-ciy8E/s400/masterpages_image1.jpg" border="0" /&gt;&lt;/a&gt; The master page already has the contentplaceholder control which is used to hold and display your contents. Let's delete that contentplaceholder and add it by our self. In this case we will create two content place holders. One will be on the left and other one on the right.&lt;br /&gt;&lt;br /&gt;After you insert the contentplaceholder control inside your table your master page will look something like this:&lt;br /&gt;&lt;a href="http://bp1.blogger.com/_jU-AORtFHik/R2jzNhMhloI/AAAAAAAAADA/nZ625zQEbG0/s1600-h/masterpages_image3.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5145629987845543554" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://bp1.blogger.com/_jU-AORtFHik/R2jzNhMhloI/AAAAAAAAADA/nZ625zQEbG0/s400/masterpages_image3.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;Click on the area of the contentplaceholder and write some text.&lt;/p&gt;Okay let's now make a page which can use this master page.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Using the master page in your aspx pages (Sample1.aspx):&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Just add a new aspx page and name it as "Sample1.aspx". Now you want to use the Sample1.master file in your aspx page. Just go to the html view of your page and add a MasterPageFile attribute in the page directive and delete all the other html that is written in the aspx page. The MasterPageFile attribute denotes that the Page is inheriting from the master page.&lt;br /&gt;&lt;br /&gt;After marking the attribute if you view your page it will look something like this:&lt;br /&gt;&lt;p&gt;&lt;img id="BLOGGER_PHOTO_ID_5145629794572015122" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://bp0.blogger.com/_jU-AORtFHik/R2jzCRMhlhI/AAAAAAAAACI/TYjsnHOxI80/s400/masterpages_image4.jpg" border="0" /&gt;Check to see if your content1 and content2 is inheriting from the master cause if they are not than it means that you are making custom contentplaceholder controls. Just right click on the Content and select smart tag and reference to the master so it will populate the boxes with the data extracted from the master pages. Now if you run the Sample1.aspx page you will see the content will be coming from the master file. NOTE: Don't forget to build your application after making changes in the master file. In the above example I Introduced you to the master pages with displaying simple text in the content pages. Let's see what else we can do using the master pages. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Adding other controls in Master pages (Sample2.aspx):&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;We are not only limited to adding text in the master pages but we can easily add any other server or html control in it. Let's add some controls to the master page. In this example I have added some hyperlinks and a image control to the master page. Your master page will look something like this after adding controls. &lt;a href="http://bp0.blogger.com/_jU-AORtFHik/R2jzCRMhliI/AAAAAAAAACQ/wi-9uZiIsYM/s1600-h/masterpages_image5.jpg"&gt;&lt;/p&gt;&lt;img id="BLOGGER_PHOTO_ID_5145629794572015138" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://bp0.blogger.com/_jU-AORtFHik/R2jzCRMhliI/AAAAAAAAACQ/wi-9uZiIsYM/s400/masterpages_image5.jpg" border="0" /&gt;&lt;/a&gt; Now the cool thing is that you don't have to do anything to make this appear on the aspx page since you have already made a reference to the master page in your aspx page using the "MasterPageFile" attribute in the page directive. So, once you run the page you will see hyperlinks and the image on your aspx page.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Setting content section to be custom section (Sample3.aspx and Sample3.master):&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Sometimes we don't want to add all the information from the master pages. Consider a content section which is not same for all the pages. This can be the detail on the page like about the company or the contacts of the company. In this example we will see that how we can enter our own contents which are not same for all the pages. Up till now you might be pretty comfortable in making the master pages. Let's make the master page which looks something like this: &lt;/p&gt;&lt;p&gt;&lt;a href="http://bp1.blogger.com/_jU-AORtFHik/R2jzChMhljI/AAAAAAAAACY/QCg9qfF_P6A/s1600-h/masterpages_image6.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5145629798866982450" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://bp1.blogger.com/_jU-AORtFHik/R2jzChMhljI/AAAAAAAAACY/QCg9qfF_P6A/s400/masterpages_image6.jpg" border="0" /&gt;&lt;/a&gt; As you can see its pretty simple master page. The left content consists of the menu which contains the hyperlinks. The right content contains the calendar control and the middle content is left blank.&lt;br /&gt;Once you reference this master page in your aspx page you will see something like this when you run the page (Don't forget to build the application first when running).&lt;br /&gt;&lt;a href="http://bp1.blogger.com/_jU-AORtFHik/R2jzChMhlkI/AAAAAAAAACg/3TdRWGfxGQI/s1600-h/masterpages_image7.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5145629798866982466" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://bp1.blogger.com/_jU-AORtFHik/R2jzChMhlkI/AAAAAAAAACg/3TdRWGfxGQI/s400/masterpages_image7.jpg" border="0" /&gt;&lt;/a&gt; As you can see the middle section is black. Now go back to the aspx page design view and right click on the middle section and select show smart tag and select "create custom content". This will allow you to enter the information in the middle content place holder control.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://bp1.blogger.com/_jU-AORtFHik/R2jzChMhllI/AAAAAAAAACo/wX7eljVYCHE/s1600-h/masterpages_image8.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5145629798866982482" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://bp1.blogger.com/_jU-AORtFHik/R2jzChMhllI/AAAAAAAAACo/wX7eljVYCHE/s400/masterpages_image8.jpg" border="0" /&gt;&lt;/a&gt; Now, as you see in the above image that the content you entered in the custom content section are added to the page rather than the contents from the master file. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Nesting Master Pages (SiteMaster.master,SectionMaster.master,Sample4.aspx):&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;You can also nest one master to the other. We will have to switch to code for this feature since the visual designer does not give you the facility to nest master pages.&lt;br /&gt;So, this means that we have to write code to achieve this so lets do it. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;SiteMaster.master:&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;The Site master master page will only contain the ContentPlaceHolder control which will display a heading saying that it is a site master page and not a section page. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;SectionMaster.master:&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Now, lets see the section master page which will inherit from the sitemaster page. &lt;%@ Master MasterPageFile="~/SiteMaster.master" Language="C#" CompileWith="SectionMaster.master.cs" ClassName="SectionMaster_master" %&gt;&lt;br /&gt;&lt;asp:content id="MasterContent" runat="Server" contentplaceholderid="SiteContentPlaceHolder"&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5145634669359896210" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 466px; CURSOR: hand; HEIGHT: 198px; TEXT-ALIGN: center" height="153" alt="" src="http://bp3.blogger.com/_jU-AORtFHik/R2j3eBMhlpI/AAAAAAAAADI/Y-RYaKo6hqc/s400/1.JPG" width="466" border="0" /&gt;&lt;/p&gt;&lt;/asp:content&gt;&lt;p&gt;See the first line, you will find it amazing but yes you can do like this. You can inherit or nest one master page inside the other. Now let's see the webform which uses all this nested master pages. In the next line we included the Content place holder control from the site master control. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Sample4.aspx:&lt;/strong&gt;&lt;img id="BLOGGER_PHOTO_ID_5145644152647685810" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://bp0.blogger.com/_jU-AORtFHik/R2kAGBMhlrI/AAAAAAAAADY/k9pe3Q9nRPk/s400/1.JPG" border="0" /&gt;&lt;/p&gt;&lt;br /&gt;&lt;?xml:namespace prefix = asp /&gt;&lt;asp:content id="MasterContent" runat="Server" contentplaceholderid="SiteContentPlaceHolder"&gt;&lt;/asp:content&gt;&lt;strong&gt;&lt;a href="http://lakshminarayana.goud.googlepages.com/MasterPages.zip"&gt;Click Here to Download the Source Code&lt;/a&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36836321-2372805635452422586?l=cdotnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cdotnet.blogspot.com/feeds/2372805635452422586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=36836321&amp;postID=2372805635452422586' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/2372805635452422586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/2372805635452422586'/><link rel='alternate' type='text/html' href='http://cdotnet.blogspot.com/2007/12/ground-up-master-pages-in-aspnet-20.html' title='Ground Up : Master Pages in ASP.NET 2.0'/><author><name>narayana</name><uri>http://www.blogger.com/profile/01832239949875659847</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp0.blogger.com/_jU-AORtFHik/R2jzNRMhlmI/AAAAAAAAACw/tOqcT-ciy8E/s72-c/masterpages_image1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36836321.post-6404965788051819213</id><published>2007-11-27T01:42:00.000-08:00</published><updated>2007-11-27T01:44:55.875-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Caching'/><title type='text'>Caching Overview</title><content type='html'>Caching is a technique widely used in computing to increase performance by keeping frequently accessed or expensive data in memory. In the context of a Web application, caching is used to retain pages or data across HTTP requests and reuse them without the expense of recreating them.&lt;br /&gt;&lt;br /&gt;ASP.NET has three kinds of caching that can be used by Web applications:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://samples.gotdotnet.com/quickstart/aspplus/doc/outputcaching.aspx"&gt;Output caching&lt;/a&gt;, which caches the dynamic response generated by a request. &lt;/li&gt;&lt;li&gt;&lt;a href="http://samples.gotdotnet.com/quickstart/aspplus/doc/fragmentcaching.aspx"&gt;Fragment caching&lt;/a&gt;, which caches portions of a response generated by a request.&lt;/li&gt;&lt;li&gt;&lt;a href="http://samples.gotdotnet.com/quickstart/aspplus/doc/datacaching.aspx"&gt;Data caching&lt;/a&gt;, which caches arbitrary objects programmatically. To support this, ASP.NET provides a full-featured cache engine that allows programmers to easily retain data across requests.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Output caching is useful when the contents of an entire page can be cached. On a heavily accessed site, caching frequently accessed pages for even a minute at a time can result in substantial throughput gains. While a page is cached by the output cache, subsequent requests for that page are served from the output page without executing the code that created it&lt;/p&gt;&lt;p&gt;Sometimes it is not practical to cache an entire page - perhaps portions of the page must be created or customized for each request. In this case, it is often worthwhile to identify objects or data that are expensive to construct and are eligible for caching. Once these items are identified, they can be created once and then cached for some period of time. Additionally, fragment caching can be used to cache regions of a page's output.&lt;/p&gt;&lt;p&gt;Choosing the time to cache an item can be an interesting decision. For some items, the data might be refreshed at regular intervals or the data is valid for a certain amount of time. In that case, the cache items can be given an expiration policy that causes them to be removed from the cache when they have expired. Code that accesses the cache item simply checks for the absence of the item and recreates it, if necessary. &lt;/p&gt;&lt;p&gt;The ASP.NET cache supports file and cache key dependencies, allowing developers to make a cache item dependent on an external file or another cache item. This technique can be used to invalidate items when their underlying data source changes.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36836321-6404965788051819213?l=cdotnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cdotnet.blogspot.com/feeds/6404965788051819213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=36836321&amp;postID=6404965788051819213' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/6404965788051819213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/6404965788051819213'/><link rel='alternate' type='text/html' href='http://cdotnet.blogspot.com/2007/11/caching-overview.html' title='Caching Overview'/><author><name>narayana</name><uri>http://www.blogger.com/profile/01832239949875659847</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36836321.post-943596641628390214</id><published>2007-11-20T22:03:00.000-08:00</published><updated>2007-11-20T22:11:42.650-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Global.asax'/><title type='text'>Fixing the Global.asax in ASP.NET 2.0</title><content type='html'>For some reason ASP.NET 2.0 has gone away from the code behind model to the script model for its Global.asax pages. I ran into this when looking at loading configuration data into global statics on application start in a web service.&lt;br /&gt;&lt;br /&gt;When I created a default web service project with Visual Studio 2005 first I found no global.asax page was created. Why its not there by default I do not know as you could easily remove it if not needed, and a empty skeletal one has no performance impact anyway.&lt;br /&gt;&lt;br /&gt;To add a global.asax, (or web.config for that matter), simply right click the web site or web server project in your solution explorer, select Add New Item from the context menu and then choose Global Application Class (or Web Configuration File for a web.config).&lt;br /&gt;&lt;br /&gt;Happy that I finally had a Global.asax in my project, I opened it only to find that there was no class present! With the scripting page model you get a skeletal global.asax something similar to:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img id="BLOGGER_PHOTO_ID_5135171119902604898" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://bp1.blogger.com/_jU-AORtFHik/R0PK7R6jvmI/AAAAAAAAABE/Js1meXoDA_Y/s400/code.jpg" border="0" /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;The problem as i see it is two fold.&lt;/p&gt;Firstly there is no class object that can be easily referenced from elsewhere in your application. If you were to load configuration information in the application_start event and store it in a global static, you cannot access that static from elsewhere in your application there is no class name to reference by.&lt;br /&gt;&lt;br /&gt;Secondly, as there is no class in the global.asax, you cant use "using" statements in the code easily. There may be a way to do this but it doesnt instantly come to hand. If you place a using before the script tag, the keyword isnt recognised. If you place a using after the script tag its not allowed as you are already inside an implicit class!&lt;br /&gt;&lt;br /&gt;After a roam on the internet I came up with an excellent reply post by Scott Allen that showed that you can switch back to the code behind model using the inherits attribute to the Application tag:&lt;br /&gt;&lt;br /&gt;&lt;%@ Application Language="C#" Inherits="Global" %&gt;&lt;br /&gt;&lt;br /&gt;The only other step is to copy the code within the script tag to a normal class file called Global.cs which you add to the project. Then delete the script tag. An example follows:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img id="BLOGGER_PHOTO_ID_5135171240161689202" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://bp1.blogger.com/_jU-AORtFHik/R0PLCR6jvnI/AAAAAAAAABM/FFM9RrnXf3M/s400/code2.0" border="0" /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Thus I now have simple and consistant use of the using keyword along with a class that is accessible from the rest of the web service to get at preloaded configuration information. My config value in this example can now be access by :&lt;/p&gt;&lt;p&gt;Global.ConfigKeyValue&lt;/p&gt;&lt;p&gt;All this is of course still possible within the script model. You dont have to use using statements and can explicitly denote classes. You also can probably store configuration items into the application cache collection instead of your own statics. However, when migrating some older applications that were written using statics, the fact that you can still use the code behind model is quite usefull. Personally I prefer the older method as it provides consistenct and I dont think a dynamic recompile on changing global.asax values is that useful or even appropriate. &lt;/p&gt;&lt;p&gt;But I am interested in knowning the rationale for why the VS2005 ASP team have gone down this change path.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36836321-943596641628390214?l=cdotnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cdotnet.blogspot.com/feeds/943596641628390214/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=36836321&amp;postID=943596641628390214' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/943596641628390214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/943596641628390214'/><link rel='alternate' type='text/html' href='http://cdotnet.blogspot.com/2007/11/fixing-globalasax-in-aspnet-20.html' title='Fixing the Global.asax in ASP.NET 2.0'/><author><name>narayana</name><uri>http://www.blogger.com/profile/01832239949875659847</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp1.blogger.com/_jU-AORtFHik/R0PK7R6jvmI/AAAAAAAAABE/Js1meXoDA_Y/s72-c/code.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36836321.post-4117271080649794560</id><published>2007-05-24T00:48:00.000-07:00</published><updated>2007-11-27T02:06:16.828-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='GridView'/><title type='text'>Create a scrollable Gridview in asp.net 2.0</title><content type='html'>&lt;strong&gt;&lt;span style="font-size:130%;color:#3333ff;"&gt;Introduction&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:130%;color:#3333ff;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;Using Javascript's cloneNode ,we can clone a table's header,so we can make a gridview to be scrollable.This method isn't set some long css.&lt;br /&gt;&lt;br /&gt;In asp.net 2.0's Page_Load event,we must add style for GridView, and this MUST for IE and Firefox can work! protected void Page_Load( object sender, EventArgs e )&lt;br /&gt;{&lt;br /&gt;if (!IsPostBack)&lt;br /&gt;{&lt;br /&gt;GridView1.Attributes.Add("style", "table-layout:fixed");&lt;br /&gt;GridView1.DataSource = CreateDataSource();&lt;br /&gt;GridView1.DataBind();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;Next,we must add some javascript for it:function start()&lt;br /&gt;{&lt;br /&gt;var t = document.getElementById("");&lt;br /&gt;var t2 = t.cloneNode(true)&lt;br /&gt;for(i = t2.rows.length -1;i &gt; 0;i--)&lt;br /&gt;t2.deleteRow(i)&lt;br /&gt;t.deleteRow(0)&lt;br /&gt;a.appendChild(t2)&lt;br /&gt;}&lt;br /&gt;window.onload = start&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36836321-4117271080649794560?l=cdotnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cdotnet.blogspot.com/feeds/4117271080649794560/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=36836321&amp;postID=4117271080649794560' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/4117271080649794560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/4117271080649794560'/><link rel='alternate' type='text/html' href='http://cdotnet.blogspot.com/2007/05/create-scrollable-gridview-in-aspnet-20.html' title='Create a scrollable Gridview in asp.net 2.0'/><author><name>narayana</name><uri>http://www.blogger.com/profile/01832239949875659847</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36836321.post-1639004534255341915</id><published>2006-12-14T23:01:00.000-08:00</published><updated>2007-11-27T02:06:04.865-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DataGrid'/><title type='text'>Specifying Paging Behavior in a DataGrid Control</title><content type='html'>Automatic versus Manual Paging&lt;br /&gt;The page displayed by the grid is determined by its CurrentPageIndex property. The built-in controls set this property automatically; if you are providing custom navigation controls, you set this yourself. After the CurrentPageIndex is set, the grid should be re-bound to the data source. The grid will recreate the entire data set and automatically move to the appropriate place in the data set. It then displays enough rows to make up one page of the grid.&lt;br /&gt;If you are working with a large data set, recreating the entire data set each time users navigate to a new page can degrade performance. In this case, you might prefer to get data in page-size "chunks" — that is, retrieve just a page worth of records at a time. To do that, you turn off the automatic paging feature of the grid so that it does not assume that it is working with the entire data set. You then manually get the correct number of rows to fill the grid.&lt;br /&gt;For details, see &lt;a href="http://authors.aspalliance.com/aspxtreme/webforms/controls/specifyingpagingbehaviorindatagrid.aspx#manual"&gt;Creating Manual Paging&lt;/a&gt; below.&lt;br /&gt;Using the Built-In Paging Controls&lt;br /&gt;To use default paging, you set properties to enable paging, set the page size, and specify the style of the paging controls. Paging controls are LinkButton controls. You can choose from these types:&lt;br /&gt;Next and previous buttons. The button captions can be any text you want.&lt;br /&gt;Page numbers, which allow users to jump to a specific page. You can specify how many numbers are displayed; if there are more pages, an ellipsis ( ... ) is displayed next to the numbers.&lt;br /&gt;You must also create an event-handling method that responds when users click a navigation control.&lt;br /&gt;To use the built-in paging controls&lt;br /&gt;Set the control's AllowPaging property to true.&lt;br /&gt;Set the PageSize property to the number of items to display per page.&lt;br /&gt;To set the appearance of the paging buttons, include a &lt;pagerstyle&gt;element into the page as a child of the DataGrid control. For syntax, see &lt;a href="http://authors.aspalliance.com/aspxtreme/aspnet/syntax/datagridwebcontrol.aspx"&gt;DataGrid Control Syntax&lt;/a&gt;.&lt;br /&gt;Create a handler for the grid's PageIndexChanged event to respond to a paging request. The DataGridPageChangedEventsArgs enumeration contains the NewPageIndex property, which is the page the user would like to browse to. Set the grid's CurrentPageIndex property to e.NewPageIndex, then rebind the data.&lt;br /&gt;The following code snippet shows the typical logic for the PageIndexChanged event handler.&lt;br /&gt;void setPage ( object src, DataGridPageChangedEventArgs e ) {&lt;br /&gt;// set CurrentPageIndex to the page the user clicked.&lt;br /&gt;myGrid.CurrentPageIndex = e.NewPageIndex;&lt;br /&gt;// fetch and rebind the data.&lt;br /&gt;BindGrid ( );&lt;br /&gt;}Sub setPage ( src As Object, e As DataGridPageChangedEventArgs )&lt;br /&gt;' set CurrentPageIndex to the page the user clicked.&lt;br /&gt;myGrid.CurrentPageIndex = e.NewPageIndex&lt;br /&gt;' fetch and rebind the data.&lt;br /&gt;BindGrid ( )&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Providing Custom Navigation Controls&lt;br /&gt;You can provide your own navigation buttons and manipulate the CurrentPageIndex property of the DataGrid. The DataGrid will still take care of breaking the data source into appropriate pages and displaying the selected page.&lt;br /&gt;When you create manual paging, you can use any way you like to set the pager style that the grid should display.&lt;br /&gt;To provide custom navigation controls&lt;br /&gt;Add server controls to the Web Forms page that the user can use to navigate. For example, you may want to create ImageButton controls with forward and reverse images on them.&lt;br /&gt;In the event handlers for the navigation controls, set the DataGrid control's CurrentPageIndex property to the page to go to, and then rebind the grid to the data source.&lt;br /&gt;The below snippet shows how you can create code for a custom navigation panel that allow the user to go to the first, last, previous, or next page. The paging elements are defined as &lt;asp:button&gt;controls whose CommandArgument property is set to indicate what page they go to. All four buttons call the following method when they are clicked.&lt;br /&gt;void setPageCustom ( object src, EventArgs e ) {&lt;br /&gt;// used by custom paging UI&lt;br /&gt;string direction = ( ( Button ) sender ).CommandArgument;&lt;br /&gt;switch ( direction ) {&lt;br /&gt;case ( "first" ) :&lt;br /&gt;myGrid.CurrentPageIndex = 0;&lt;br /&gt;break;&lt;br /&gt;case ( "prev" ) :&lt;br /&gt;if ( myGrid.CurrentPageIndex &gt; 0 )&lt;br /&gt;myGrid.CurrentPageIndex --;&lt;br /&gt;break;&lt;br /&gt;case ( "next" ) :&lt;br /&gt;if ( myGrid.CurrentPageIndex &lt; ( myGrid.PageCount - 1 ) ) myGrid.CurrentPageIndex ++; break; case ( "last" ) : myGrid.CurrentPageIndex = ( myGrid.PageCount - 1 ); break; } BindGrid ( ); }Sub setPageCustom ( src As Object, e As EventArgs ) ' used by custom paging UI Dim direction As String = CType ( sender, Button ).CommandName Select Case direction Case "first" myGrid.CurrentPageIndex = 0 Case "prev" myGrid.CurrentPageIndex = _ Math.Max ( 0, myGrid.CurrentPageIndex - 1 ) Case "next" myGrid.CurrentPageIndex = _ Math.Min ( myGrid.PageCount - 1, myGrid.CurrentPageIndex + 1 ) Case "last" myGrid.CurrentPageIndex = myGrid.PageCount - 1 End Select BindGrid ( ) End Sub &lt;a name="manual"&gt;&lt;/a&gt;&lt;br /&gt;Creating Manual Paging&lt;br /&gt;By default, the DataGrid control recreates the data set each time the user navigates to a new page and then calculates which rows to display for the requested page. This may not be efficient, however, in applications that need to access large data sets.&lt;br /&gt;By using the AllowCustomPaging property of the DataGrid, you can have complete control over which records are displayed. Custom paging improves performance by reducing the amount of data moved around in the system, since you can retrieve just one page of data at a time from the data source.&lt;br /&gt;To do so, you turn off automatic paging, then take responsibility in your own code to get just the data for a single page. To create manual paging&lt;br /&gt;To be supplied.&lt;br /&gt;It is common to set this value by querying the data source the first time the page is run, as in the following example:&lt;br /&gt;[ Visual Basic ]&lt;br /&gt;[ C# ]&lt;br /&gt;void Page_Load ( object src, EventArgs e ) {&lt;br /&gt;if ( !IsPostBack ) {&lt;br /&gt;int TotalRowCount=0;&lt;br /&gt;// Query data source here and get the count of all rows you might display&lt;br /&gt;myGrid.VirtualItemCount = TotalRowCount;&lt;br /&gt;}&lt;br /&gt;myGrid.DataBind ( );&lt;br /&gt;} --&gt;&lt;br /&gt;The following examples demonstrate two different ways of using the AllowCustomPaging property to enable custom paging. One uses an autoincrement data model, and the other uses a data source with primary keys.&lt;br /&gt;&lt;/asp:button&gt;&lt;?xml:namespace prefix = asp /&gt;&lt;asp:button&gt;&lt;/asp:button&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36836321-1639004534255341915?l=cdotnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cdotnet.blogspot.com/feeds/1639004534255341915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=36836321&amp;postID=1639004534255341915' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/1639004534255341915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/1639004534255341915'/><link rel='alternate' type='text/html' href='http://cdotnet.blogspot.com/2006/12/specifying-paging-behavior-in-datagrid.html' title='Specifying Paging Behavior in a DataGrid Control'/><author><name>narayana</name><uri>http://www.blogger.com/profile/01832239949875659847</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36836321.post-116317115594288904</id><published>2006-11-10T06:47:00.000-08:00</published><updated>2007-11-27T02:05:39.965-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DataList'/><title type='text'>DataList Paging</title><content type='html'>Unlike the DataGrid, the DataList has no inbuilt paging mechanism. As with most things in .NET, however, where there is a will, there is a way.&lt;br /&gt;The secret to implementing paging in the DataList control lies not in the control itself, but in the DataAdapter's Fill method which can be overloaded in several different ways. One way to overload it is to pass the arguments DataSet, starting record, number of records, and the table name or index. Number of records is analogous to "page size" in a DataGrid. Starting record is the "index" of the current starting record. For example, if our page size is 10 and we are on the first page of records, then starting record would be 0 and our 10 displayed rows would be 0 through 9. If the NextPage button is clicked, then starting record would be 10 and displayed rows would be 10 through 19, etc. All we need then is a mechanism for specifying page size (number of records) and current index (starting record). Page size is normally a static value that can be specified once in the program. Starting record (current index) will change from page to page and must be tracked within our code-behind logic.&lt;br /&gt;We will use three invisible label controls on the .aspx page to store total record count, current index, and page size. The .aspx page is presented below. I used images (VCR buttons) for the paging mechanism. I needed an html element where I could include an OnServerClick event and I wanted to make the images appear as links (cursor = hand). The easiest way to do this was to use links to a bookmark at the top of the page. The rest of the markup should be self evident.&lt;br /&gt;&lt;br /&gt;The code-behind page is shown in two parts below. This first part shows the Page_Load event and the BindTheData subroutine. Since the data must be bound to the DataList control with each page change it is convenient, and more efficient to move the data binding to a routine of its own. It is in the latter third of the BindTheData code that we make use of overloading the Fill method of the DataAdapter. That is done with the line:&lt;br /&gt;&lt;br /&gt;dataAdapter.Fill (dataSet, Cint(lblCurrentIndex.Text), CInt(lblPageSize.Text), "Customers") ;&lt;br /&gt;&lt;br /&gt;The above line is saying Fill the DataSet, with data beginning at record zero (since CurrentIndex happens to be 0 the first time through), with 10 rows (our specified page size), from the table "Customers". As we click the next and previous page buttons CurrentIndex will change appropriately and the correct page of data will be displayed.&lt;br /&gt;&lt;br /&gt;Imports System.Data&lt;br /&gt;Imports System.Data.SqlClient&lt;br /&gt;Imports System.Configuration&lt;br /&gt;Imports Microsoft.VisualBasicPublic&lt;br /&gt;Class PagingDataList : Inherits System.Web.UI.Page&lt;br /&gt;Protected lblCurrentIndex As System.Web.UI.WebControls.Label&lt;br /&gt;Protected lblRecordCount As System.Web.UI.WebControls.Label&lt;br /&gt;Protected dtlCustomers As System.Web.UI.WebControls.DataList&lt;br /&gt;Protected lblPageSize As System.Web.UI.WebControls.Label&lt;br /&gt;Protected lblCounts As System.Web.UI.WebControls.Label&lt;br /&gt;&lt;br /&gt;Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)&lt;br /&gt;If Not Page.IsPostBack() Then&lt;br /&gt;BindTheData()&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub BindTheData()&lt;br /&gt;Dim objConn As New SqlConnection(ConfigurationSettings.AppSettings("NorthwindConnection"))&lt;br /&gt;Dim strSql As String = "SELECT CompanyName, ContactName, ContactTitle, Country, Phone FROM Customers"&lt;br /&gt;Dim dataAdapter As New SqlDataAdapter(strSql, objConn)&lt;br /&gt;Dim dataSet As New DataSet()&lt;br /&gt;If Not Page.IsPostBack() Then&lt;br /&gt;dataAdapter.Fill(dataSet)&lt;br /&gt;lblRecordCount.Text = CStr(dataSet.Tables(0).Rows.Count)&lt;br /&gt;dataSet = Nothing&lt;br /&gt;dataSet = New DataSet()&lt;br /&gt;End If&lt;br /&gt;dataAdapter.Fill (dataSet, Cint(lblCurrentIndex.Text), CInt(lblPageSize.Text), "Customers")&lt;br /&gt;dtlCustomers.DataSource = dataSet.Tables("Customers").DefaultView&lt;br /&gt;dtlCustomers.DataBind()&lt;br /&gt;objConn.Close()&lt;br /&gt;ShowCounts()&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;The remainder of the code-behind page is shown below. The first four routines are for handling the button click on our First, Previous, Next, and Last navigation links. Essentially all they do is set the correct value for CurrentIndex. The Previous and Next routines simple increment or decrement the CurrentIndex by the PageSize as appropriate. First and Last are special cases in that First just always sets CurrentIndex to 0, while Last subtracts PageSize from RecordCount. The last routine (ShowCounts) just updates our status line showing which of how many pages we are currently displaying.&lt;br /&gt;&lt;br /&gt;Public Sub ShowFirstPage(ByVal s As System.Object, ByVal e As System.EventArgs)&lt;br /&gt;lblCurrentIndex.Text = "0"&lt;br /&gt;BindTheData()&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Public Sub ShowPreviousPage(ByVal s As System.Object, ByVal e As System.EventArgs)&lt;br /&gt;lblCurrentIndex.Text = Cstr(Cint(lblCurrentIndex.Text) - CInt(lblPageSize.Text))&lt;br /&gt;If CInt(lblCurrentIndex.Text) &lt; text = "0" text =" CStr(CInt(lblCurrentIndex.Text)" intmod =" CInt(lblRecordCount.Text)"&gt; 0 Then&lt;br /&gt;lblCurrentIndex.Text = Cstr(CInt(lblRecordCount.Text) - intMod)&lt;br /&gt;Else&lt;br /&gt;lblCurrentIndex.Text = Cstr(CInt(lblRecordCount.Text) - CInt(lblPageSize.Text))&lt;br /&gt;End If&lt;br /&gt;BindTheData()&lt;br /&gt;End&lt;br /&gt;Sub Private Sub ShowCounts()&lt;br /&gt;lblCounts.Text = "Total Rows: &lt;b&gt;" &amp;amp; lblRecordCount.Text&lt;br /&gt;lblCounts.Text += "&lt;/b&gt; Page:&lt;b&gt; "&lt;br /&gt;lblCounts.Text += CStr(CInt(CInt(lblCurrentIndex.Text) / CInt(lblPageSize.Text)+1))&lt;br /&gt;lblCounts.Text += "&lt;/b&gt; of &lt;b&gt;" If (CInt(lblRecordCount.Text) Mod CInt(lblPageSize.Text)) &gt; 0 Then&lt;br /&gt;lblCounts.Text += CStr(Fix(CInt(lblRecordCount.Text) / CInt(lblPageSize.Text)+1))&lt;br /&gt;Else&lt;br /&gt;lblCounts.Text += CStr(Fix(lblRecordCount.Text) / CInt(lblPageSize.Text))&lt;br /&gt;End If&lt;br /&gt;lblCounts.Text += "&lt;/b&gt; "&lt;br /&gt;End Sub&lt;br /&gt;End Class&lt;br /&gt;&lt;br /&gt;A fair amount of code has been presented to implement paging in the DataList control, but I think if you will run the program and then take a careful look at each section of code at a time, you will understand that the process is really not all that complicated. Please be advised that one drawback of this method is that all rows of data from the table are being brought back with each page change. We are only displaying the specific rows we want. For a large table this could become unweildy. Good luck!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36836321-116317115594288904?l=cdotnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cdotnet.blogspot.com/feeds/116317115594288904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=36836321&amp;postID=116317115594288904' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/116317115594288904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36836321/posts/default/116317115594288904'/><link rel='alternate' type='text/html' href='http://cdotnet.blogspot.com/2006/11/datalist-paging.html' title='DataList Paging'/><author><name>narayana</name><uri>http://www.blogger.com/profile/01832239949875659847</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
