Hi Everybody,
I am creating a webpart to display data from SharePoint lists. I am using
SPGridView for this. First time I am using
SPGridView. I have to accomplish the following goals with my
SPGridView.
I could do all my jobs fine with a normal
GridView but when I started using a
SPGridView trouble started.
I reallly want to enable filtering but I really don't know how can implement it with the
SPGridView.
Also I have another weired problem. The
SPGridView is not showing the paging buttons. But it is accepting the
PageSize property, only buttons are not visible.
I really dont know why this is happening.
Here is the code I am trying out.
Code:
protected override void CreateChildControls()
{
oGrid = new SPGridView();
oDS = new SPDataSource();
oGrid.AllowPaging = true;
oGrid.PageSize = 3;
oGrid.EnableViewState = true;
oGrid.PagerTemplate = null;
oGrid.TemplateControl = null;
oGrid.AutoGenerateColumns = false;
oGrid.PageIndexChanging += new GridViewPageEventHandler(oGrid_PageIndexChanging);
oDS.List = SPContext.Current.Web.Lists["Contacts"];
oGrid.AutoGenerateColumns = false;
BoundField colTitle = new BoundField();
colTitle.DataField = "Last Name";
colTitle.HeaderText = "Last Name";
oGrid.Columns.Add(colTitle);
oGrid.DataSource = oDS;
this.Controls.Add(this.oGrid);
oGrid.DataBind();
}
void oGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
oGrid.PageIndex = e.NewPageIndex;
oGrid.DataBind();
}
Please help me.
Arun