This project is read-only.

Search in Grid

May 2, 2012 at 7:36 AM

Hi Is there anything inbuilt for searching in Grid.


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Admin_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
    <ext:PageManager ID="PageManager1" runat="server" />
        <ext:Grid Title="List Of Registered Students" runat="server" ID="gvStudents" Width="800px"
            PageSize="5" ShowBorder="true" ShowHeader="true" AutoHeight="true" EnableCheckBoxSelect="True"
            DataKeyNames="StudId" EnableRowNumber="True">
                <ext:BoundField DataField="StudId" HeaderText="StudId" Width="30" Hidden="true" runat="server" />
                <ext:BoundField DataField="Name" HeaderText="Name" Width="180" runat="server" DataToolTipField="Name" />
                <ext:BoundField DataField="Area" HeaderText="Area" Width="120" runat="server" />
                <ext:BoundField DataField="Mobile" HeaderText="Contact" Width="80" runat="server" />
                <ext:BoundField DataField="ParrentOfficeTelNo" HeaderText="Parent Contact" Width="80"
                    runat="server" />
                <ext:BoundField DataField="AdmissionDate" HeaderText="Adm. Date" Width="110" runat="server" />
                <ext:BoundField DataField="STDName" HeaderText="Adm. Std" Width="100" runat="server" />
                        <ext:TextBox ID="txtSearch" runat="server" Label="Label" Text="" EmptyText="Search by Student Name"
                        <ext:Button ID="Button1" runat="server" Text="Search" OnClick="Button1_Click" EnablePostBack="true"></ext:Button>

Code Behind 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Admin_Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)



    private void bindStudentGrid()

        NewUser nu = new NewUser();
        nu.StudId = 0;
        DataSet dsStud = nu.getStudent(nu);
        if (dsStud.Tables[0].Rows.Count > 0)
            gvStudents.DataSource = dsStud;

        //lblmsg.Text = "List Of Student";
    protected void Button1_Click(object sender, EventArgs e)
        txtSearch.Text = "Hi";
        NewUser nu = new NewUser();

        nu.FirstName = txtSearch.Text;

        DataSet dsStud = nu.getSearchStudent(nu);
        if (dsStud.Tables[0].Rows.Count > 0)

            gvStudents.DataSource = dsStud;
            gvStudents.DataBind(); //Object reference not set to an instance of an object.




May 2, 2012 at 9:02 AM