In this article, you will learn how to work with the ASP.Net (C#) Grid View Control using the data from a Microsoft SharePoint (MOSS 2007) custom list. In this article we will use ASP.Net (C#) Grid View Control for displaying data from the SharePoint (MOSS 2007) custom list in the SharePoint (MOSS 2007) user control. The ASP.Net (C#) Grid View Control is the best ASP.net control for displaying user friendly data (it means good layout and custom fields/columns) SharePoint (MOSS 2007) user control. I will explain this article to you in a step-by-step manner.

First of all, launch Visual Studio .NET (Start | All Programs | Microsoft Visual Studio 2005 Beta | Microsoft Visual Studio 2005 Beta 2). Create a new Web project (File | New | Web Site) and select the location where your project will be saved. Be sure that you have checked ASP.NET Web Site from the templates section and Visual Basic .NET as your language from the Language drop down box.

Click the OK button and switch to the design view by selecting the appropriate option from the IDE. Now add the item with file extension .ascx for the user control. Now in .ascx file place an instance of GridView controls from the Toolbox (See Figure 2).

Now open the .ascx file in Source mode by clicking the Source mode tab. In the source mode you will be able to see the HTML code of this grid view. In the HTML code of grid view change the name of grid view control to grdResult (ID=grdResult). For displaying custom data from the SharePoint (MOSS 2007) list you need to make some changes in the HTML of the ASP.Net Grid View Control. Suppose we are having the SharePoint (MOSS 2007) Custom List named User. The User list having the following columns:

In the ASP.Net Grid View Control, we will display the above mentioned columns from the SharePoint (MOSS 2007) Custom List named User. For this I have made some changes in the HTML view of the ASP.Net Grid View Control grdResult.

Now, for displaying data in ASP.Net (C#) Grid View Control from Microsoft SharePoint (MOSS 2007) custom list, we need to write code in C# at code behind i.e. in the .ascx.cs file of the .ascx page.I have written the two function’s for binding ASP.Net (C#) Grid View Control to the data:

Categories

About Me

Based in Bangalore, INDIA, Amit is a MCC. He has an MCA from the U.P.T.U., INDIA and holds Microsoft certifications including SharePoint 2007/2010/2013. He is an contributor to MSDN and http://amitkumarmca04.blogspot.com/. Amit have experience in SharePoint,ASP.Net with C#, Classic ASP, VB,Macros,HTML,JavaScript,JSON,BootStrap and AngularJS.