Open the team site.
Create a sample list “Employee”.
Add some values into the list.
Open Visual Studio then create a new Visual Webpart.
Enter a valid site URL then select Deploy as a Farm solution.
Create a new Visual Webpart in the project.
Now open EmployeeRegistration.ascx.
Create a GridView.
Code
- <asp:GridView ID="mygrid" runat="server" AutoGenerateColumns="false">
- <Columns>
- <asp:BoundField DataField="Name" HeaderText="
- Name" />
- <asp:BoundField DataField="Email" HeaderText="Email" />
- </Columns>
- </asp:GridView>

Now open EmployeeRegistration.ascx.cs.
Code
- using System;
- using System.ComponentModel;
- using System.Web.UI.WebControls.WebParts;
- using Microsoft.SharePoint;
- using System.Data;
- namespace BindListData.EmployeeRegistration
- {
- [ToolboxItemAttribute(false)]
- public partial class EmployeeRegistration : WebPart
- {
- // Uncomment the following SecurityPermission attribute only when doing Performance Profiling on a farm solution
- // using the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
- // for production. Because the SecurityPermission attribute bypasses the security check for callers of
- // your constructor, it's not recommended for production purposes.
- // [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
- public EmployeeRegistration()
- {
- }
- protected override void OnInit(EventArgs e)
- {
- base.OnInit(e);
- InitializeControl();
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- SPWeb web = SPContext.Current.Web;
- SPList list = web.Lists["Employee"];
- SPListItemCollection items = list.Items;
- mygrid.DataSource = items.GetDataTable();
- mygrid.DataBind();
- }
- }
- }
Now the result.


Happy SharePointing!
Regards: Vinodh.N (SharePoint developer / administrator).


Mahipal ReddyPosted May 24, 2018, 8:29 PM EDT
Simple and good one
venkat KotaiahPosted Dec 7, 2017, 9:19 PM EST
Thanks a lot it helped me lot
Vinodh NarayananPosted Aug 24, 2015, 9:57 PM EDT
Vaikesh K P Thanks a lot
Vaikesh K PPosted Aug 24, 2015, 9:39 PM EDT
Nice
Vinodh NarayananPosted Aug 24, 2015, 3:44 AM EDT
Gowtham Rajamanickam Thanks a lot
Gowtham RajamanickamTOP 100Posted Aug 24, 2015, 3:25 AM EDT
good one...
Vinodh NarayananPosted Aug 23, 2015, 8:23 PM EDT
Karthikeyan K Thank u
Karthikeyan KPosted Aug 23, 2015, 7:26 PM EDT
Thanks for share sir..
Vinodh NarayananPosted Aug 23, 2015, 7:14 PM EDT
Gopi Chand thank you
Gopi ChandPosted Aug 23, 2015, 9:51 AM EDT
Very nice
Vinodh NarayananPosted Aug 23, 2015, 8:51 AM EDT
Santhakumar Munuswamy Thanks sir
Santhakumar MunuswamyPosted Aug 23, 2015, 7:34 AM EDT
Thanks for Nice article
Vinodh NarayananPosted Aug 23, 2015, 5:59 AM EDT
Thank you guys
Mohammed IbrahimPosted Aug 23, 2015, 5:48 AM EDT
nice....
Sibeesh VenuTOP 100Posted Aug 22, 2015, 11:47 PM EDT
Nice Share
Vinodh NarayananPosted Aug 22, 2015, 10:46 PM EDT
Thanks a lot friends
Rajeesh MenothPosted Aug 22, 2015, 10:41 PM EDT
Nice One
RakeshPosted Aug 22, 2015, 9:28 PM EDT
Good one