I have sp grid view in my application page, I am binding some data to the sp grid vie, now I want to apply filtering for this grid. I am googling on this one since 2 days, I am unable to get the exact link to my question. Please any suggest me some links.
Here the grid view binding code
protected void BindToDataTable()
{
string siteUrl = SPContext.Current.Web.Url;
using (SPSite oSite = new SPSite(siteUrl))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPList oListSCat = oWeb.Lists["listHelpDesk"];
SPListItemCollection olistItemColl = oListSCat.Items;
if (!dt.Columns.Contains("Functional Area"))
{
dt.Columns.Add("FunctionalArea");
}
if (!dt.Columns.Contains("Category"))
{
dt.Columns.Add("Category");
}
if (!dt.Columns.Contains("SubCategory"))
{
dt.Columns.Add("SubCategory");
}
if (!dt.Columns.Contains("Tier"))
{
dt.Columns.Add("Tier");
}
if (!dt.Columns.Contains("Region"))
{
dt.Columns.Add("Region");
}
if (!dt.Columns.Contains("Subject"))
{
dt.Columns.Add("Subject");
}
if (!dt.Columns.Contains("Description"))
{
dt.Columns.Add("Description");
}
if (!dt.Columns.Contains("Attachments"))
{
dt.Columns.Add("Attachments");
}
foreach (SPListItem listItem in olistItemColl)
{
DataRow dr = dt.NewRow();
string fncArea = listItem["Functional Area"].ToString();
dr["FunctionalArea"] = fncArea.Split('#')[1];
string cat = listItem["Category"].ToString();
dr["Category"] = cat.Split('#')[1];
string scat = listItem["Subcategory"].ToString();
dr["SubCategory"] = scat.Split('#')[1];
string tier = listItem["Tier"].ToString();
dr["Tier"] = tier.Split('#')[1];
string region = listItem["Region"].ToString();
dr["Region"] = region.Split('#')[1];
dr["Subject"] = listItem["Subject"].ToString();
dr["Description"] = listItem["Description"].ToString();
dr["Attachments"] = "Download link";
dt.Rows.Add(dr);
}
ViewState["dt"] = dt;
spgrdView.PagerTemplate = null;
//spgrdView.DataBind();
}
}
}
public void BindToGridFromSession()
{
spgrdView.PagerTemplate = null;
DataTable dt = (DataTable)ViewState["dt"];
spgrdView.DataSource = dt;
spgrdView.DataBind();
}