filtering in spgridview in sharepoint

Advertisement
In this article I will explain how to create filtering in spgridview.
Take Visualwebpart,in managementUserControl.ascx write the following code.
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce222e9429c" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce222e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce222e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %> 
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce222e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="managementUserControl.ascx.cs" Inherits="Webparts.management.managementUserControl" %>

    
      
        No Data Found
    

In managementUserControl.ascx.cs write the following code.
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web;
using Microsoft.SharePoint;
using System.Data;
using System.ComponentModel;

namespace Webparts.management
{
    public partial class managementUserControl : UserControl
    {
        public static DataTable table = new DataTable();
       
        public static string ddllist;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {

              
                if (!IsPostBack)
                {
                    
                    
                    gridBind();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

               public void gridBind()
        {

            spgrid.DataBind();
        }

        public static DataTable getData()
        {
           
            SPWeb currentWeb = SPContext.Current.Web;
            SPList lst = currentWeb.Lists["ListName"];
            table = lst.GetItems().GetDataTable();
           
                      return table;
        }
}
}
Finally OutPut:

Advertisements
SHARE

Lakshmi Tulasi Jasti

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a comment