- using System;
- using System.Runtime.InteropServices;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Xml.Serialization;
- using Microsoft.SharePoint;
- using Microsoft.SharePoint.WebControls;
- using Microsoft.SharePoint.WebPartPages;
- namespace FiveNumber
- {
- [Guid("e6a48f2e-8f31-4738-8ed6-6629f985956d")]
- public class DisplayListInSpGridView : System.Web.UI.WebControls.WebParts.WebPart
- {
- SPGridView myGridView;
- SPDataSource myDataSource = new SPDataSource();
- protected override void CreateChildControls()
- {
- myGridView = new SPGridView();
- myGridView.Enabled = true;
- myGridView.AutoGenerateColumns = false;
- myGridView.ID = "gv_MyGridView";
- myGridView.AllowGrouping = true;
- myGridView.AllowGroupCollapse = true;
- myGridView.GroupField = "Country";
- myGridView.GroupDescriptionField = "Country";
- //myGridView.GroupFieldDisplayName = "Country Name";
- BoundField colTitle = new BoundField();
- colTitle.DataField = "Country";
- colTitle.HeaderText = "Country";
- this.myGridView.Columns.Add(colTitle);
- BoundField colMission = new BoundField();
- colMission.DataField = "State";
- colMission.HeaderText = "State";
- this.myGridView.Columns.Add(colMission);
- this.Controls.Add(myGridView);
- }
- protected override void Render(HtmlTextWriter writer)
- {
- SPSite site = SPContext.Current.Site;
- SPWeb web = SPContext.Current.Web;
- SPList list = web.Lists["Countries"];
- myDataSource.List = list;
- myGridView.DataSource = myDataSource;
- myGridView.DataBind();
- myGridView.RenderControl(writer);
- }
- }
- }
The greatest test of courage on earth is to bear the defeat without losing heart..
Friday, December 30, 2011
Displaying Sharepoint Custom List items in SPGridView
Subscribe to:
Post Comments (Atom)
Hey there! I just wanted to ask if you ever have any issues with
ReplyDeletehackers? My last blog (wordpress) was hacked and I ended up
losing several weeks of hard work due to no data backup.
Do you have any methods to stop hackers?
Also see my website: win money online
Those are loans because provide people every way to become money right released.
ReplyDeleteWhich means ought to be utilized in your current most
optimum systems.
Also visit my homepage payday loans uk
In the payday loans one has to pay money when they end
ReplyDeleteup being their next take home pay. So, the customer need not
be afraid about that emploi.
Here is my page : quick payday loans