I have created list and application page in visual studio for sharepoint.Now I have to show that list on that application page. I have option of using SPServices. But is there anything I can do with C# code or anything in visual studio?

2 Answers 2


i know the answer has been accepted, but to do this through code:


<SharePoint:SPGridView ID=”oGrid” runat=”server” AutoGenerateColumns=”true” >

a ebook on spgridview:


now within your aspx.cs onload method you would do:

        using (SPSite site = new SPSite(SPContext.Current.Site.Url))
            using (SPWeb web = site.OpenWeb("yourSubSiteName"))
                SPList list = web.Lists["list name"];
                SPListItemCollection items = list.Items;

                oGrid.DataSource = items.GetDataTable();

now build and goto the asox file on sharepoint and you should see a list in your aspx that has the same look and feel as the standard default list in sharepoint

  • I already mentioned SPGridView in my answer with MSDN Examples.. But thanks for the code snippet Jan 16, 2014 at 10:26
  • yes i did notice that! the example wasnt great tho, i just wanted to show a different method in showing the gridview with minimal code.
    – Ali Jafer
    Jan 16, 2014 at 10:35
  • @aliSharepoint I'm trying to add the SPGridView control to one of my apps, but I can't seem to find the Microsoft.SharePoint dll to reference? Is it possible to use when developing Apps for SharePoint Online? Jun 5, 2014 at 10:46

Yes, you can create Visual Web Parts in Visual Studio for SharePoint

Look Create Visual Web Parts in SharePoint 2010

You can use ASP.NET Controls in your Visual Web Part, you can drop this Visual Web Part after deploying your solution to any SharePoint Page (Publishing Page, Web Part Page etc.)

For showing list items you can either use GridView ASP.NET control or Repeater ASP.NET Control.. Or you can use SPGridView control which renders just like a SharePoint View.

For dropping the Visual Web Part on a Custom Application Page, you can use SharePoint Designer to drop the Web Part in your Application Page.. It will Register the assembly for the Web Part at the top of Application Page and will consume the Web Part.. Example is shown below:

Register Tag

<%@ Register tagprefix="CustomContainer" namespace="Namespace.VWP.MyVisualWebPart" assembly="Namespace, Version=, Culture=neutral, PublicKeyToken=902c3e196fff777a" %>


<CustomContainer:MyVisualWebPart runat="server" Description="MyVisualWebPart" Title="MyVisualWebPart" __MarkupType="vsattributemarkup" __WebPartId="{AC7575C2-666C-4729-B0A2-00711C90E4CB}" WebPart="true"  id="g_ac7575c2_666c_4729_b0a2_00711c90e4cb" AllowConnect="False" AllowZoneChange="False" AllowHide="False" AllowMinimize="False" AllowEdit="False" AllowClose="False" ChromeType="None"></CustomContainer:MyVisualWebPart>


No what I mean was, you can drop visual web part using SharePoint Designer and once it includes the Register directive and your web part control on the page.. You can copy these into your application page in Visual Studio..

About everything works fine when Visual Studio is in Debugging Mode.. That's because when you stop debugging, Visual studio retracts your solution.. And thus you don't have Visual Web Part in your farm, what you can try is Right Click the Project -> Click Deploy.. This will include your solution and activate the features.. when you build your solution and deploy it, it generates a WSP file in Debug folder which you can use to deploy the solution without using Visual Studio.. using Add-SPSolution and Install-SPSolution Powershell commands..

  • Thanks for solution. but I cant take visual web part in this case. because if I take this then again I have to take applicatoin page and add that newly created visual web part on that page. Is it correct way? for second solution ,this may help me SPGridView thanks for solution Jan 16, 2014 at 5:51
  • Yes, dropping a Visual Web Part on an application page is NOT considered a bad practice.. (Please someone correct me if I'm wrong).. If the answer was helpful, please tick the answer as correct Jan 16, 2014 at 5:53
  • I am new for sharepoint, But I think we cant use Sharepoint designer for droping visual web part because when I deploye the solution, then its works fine when visual studio is in running state, but as I stop this, nothing is there in the site. I may using any wrong way for doing this. and "Using SPServices to showing a list", does it make sense? please guide Jan 16, 2014 at 6:03
  • Please check my updated answer Jan 16, 2014 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.