See Detail example at Using SPGridView to display list Data WebPart
Topic Covers :
1. How to display List data with SPGridView.
Steps:
1. Drag and drop SPGridView and SPDataSource from toolbox. (If you dont have them, right click on tabs and click on choose items and select GridView and SPDatasource).
2. Write the following in Code Behind for binding SPGridView with List Data.
protected void Page_Load(object sender, EventArgs e)
{
SPSite mySite = SPContext.Current.Site;
SPWeb myWeb = mySite.OpenWeb();
SPList List = myWeb.Lists["Mylist"];
SPDataSource1.List = List ;
GridView .DataSource = SPDataSource1;
GridView .DataBind();
}
See Detail example at Using SPGridView to display list Data WebPart
5 comments:
Hi,
where do I find SPGridView and SPDataSource to add them to my toobox ?
Thanks
Add Microsoft.sharepoint.dll in the refrence section in the project.
Now in right click in tools under general tab(any tab)and select choose items. Then select SPGridView and SPDataSource libraries and they will be added along with your other.net tools.
If you are using Class library project then create a instance of SPGridView with new keyword
"create a instance of SPGridView with new keyword" hehe - well said ;)
this is rubbish. explain yourself and stop waisting everyones time.
If the "new" keyword is confusing to you, please read up on C# fundamentals. You will need to either add the SPGridView XML definition to the *.aspx document in your project, or instantiate an SPGridView in C# in the *.aspx.cs document.
Post a Comment