Home > Forum > ASP.NET > how i filtering gridview with (drop-downlist or radcombobox) multi select value with checkbox

how i filtering gridview with (drop-downlist or radcombobox) multi select value with checkbox

by thatha matha   on Oct 10, 2014   Category: ASP.NET  |  Views: 3232    |  Points: 5   |  Starter 
i have (Drop-down or radcombobox) multi Selected Value with checkbox and gridview data

after select checkbox change data in gridview

i want to Filtering get data to or gridview when i Selected Value checkbox from Drop-down or radcombobox i need the behaind code by vb code
pls help me

Bookmark and Share:
  User Reply  | Ask a question  |   Reply 
  Re :how i filtering gridview with (drop-downlist or radcombobox) multi select value with checkbox   
by Thamil
on Oct 11 2014 4:07AM
Points : 10
Hi Thath,

below sample code will help you on this. i'm using dropdown list control to filter the gridview data and display. same you can also use multiple selection from dropdown list with checkbox and filter the gridview data.

here i have loaded the employee details with department into datatable and binded with gridview control then loaded the department name in the dropdown and based on the selection in dropdown, i have filter the employee datatable and binding with gridview control again.

aspx page details:
<asp:DropDownList ID="ddlDep" Width="200px" runat="server">
<asp:ListItem Value="0">--Select--</asp:ListItem>
<asp:ListItem Value="1">Information Technoloy</asp:ListItem>
<asp:ListItem Value="2">Finance Control</asp:ListItem>
<asp:ListItem Value="3">Customer Care</asp:ListItem>
</asp:DropDownList><br /><br />
<asp:Button ID="btnSearch" runat="server" Text="Search Department"
onclick="btnSearch_Click" /><br /><br />
<asp:GridView ID="GVEmp" AutoGenerateColumns="false" runat="server">
<asp:BoundField DataField="Name" HeaderText="Name" HeaderStyle-Width="200px" />
<asp:BoundField DataField="Department" HeaderText="Department" HeaderStyle-Width="200px"/>
<asp:BoundField DataField="DepartmentID" HeaderText="DepartmentID" HeaderStyle-Width="200px"/>

Code behind part:
DataTable dtEmp = null;
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
Session["Emp"] = GetData();

if (Session["Emp"] != null)
dtEmp = (DataTable)Session["Emp"];
GVEmp.DataSource = dtEmp;

protected void btnSearch_Click(object sender, EventArgs e)
if (Session["Emp"] != null)
dtEmp = (DataTable)Session["Emp"];
if (ddlDep.SelectedValue.ToString() != "0")
var rows = from r in dtEmp.AsEnumerable()
where r.Field<string>("DepartmentID").Contains(ddlDep.SelectedValue.ToString())//if dropdown with multiple selection option then need to provide the comma seperated values here ex. 1,2,3
select new
Name = r.Field<string>("Name"),
Department = r.Field<string>("Department"),
DepartmentID = r.Field<string>("DepartmentID")
GVEmp.DataSource = rows;
GVEmp.DataSource = dtEmp;


private DataTable GetData()
DataTable dtEmp = new DataTable("Emp");
DataColumn Name = new DataColumn("Name", typeof(System.String));
DataColumn Dept = new DataColumn("Department", typeof(System.String));
DataColumn DeptId = new DataColumn("DepartmentID", typeof(System.String));
dtEmp.Columns.AddRange(new DataColumn[] { Name, Dept, DeptId });
dtEmp.Rows.Add("Ricki", "Information Technoloy","1");
dtEmp.Rows.Add("Loretta", "Finance Control","2");
dtEmp.Rows.Add("Hassen", "Customer Care","3");
dtEmp.Rows.Add("Maddox", "Customer Care", "3");
dtEmp.Rows.Add("Sheldon", "Finance Control", "2");
dtEmp.Rows.Add("Aadinath", "Customer Care", "3");
dtEmp.Rows.Add("Aakaash", "Information Technoloy", "1");
dtEmp.Rows.Add("Aamod", "Customer Care", "3");
return dtEmp;

Please let me know if you have any question on this.

Recent Post

Latest Posts