Dear all,
Once bind gridview from database i want to filter record from gridview not database.
how i can do ?
pls send me useful link.....
Regards
Niranjan Poddar
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Dipankar BiswasPosted Nov 2, 2014, 12:38 PM
http://www.asp.net/web-forms/overview/presenting-and-managing-data/model-binding/sorting-paging-and-filtering-data
Khargesh RajputPosted Nov 1, 2014, 7:33 AM
public DataTable Dt_Branch
{
get
{
object temp = ViewState["Dt_Branch"];
return temp == null ? null : temp as DataTable;
}
set
{
ViewState["Dt_Branch"] = value;
}
}
page_load
{
BindGridView();
}
protected void BindGridView()
{
DataView EmpDataView = new DataView();
EmpDataView = Dt_Branch.DefaultView;
GrdBranch.PageSize = pageSize;
totalRowCount = EmpDataView.Count;
GrdBranch.DataSource = EmpDataView;
GrdBranch.DataBind();
}
btnsearchclick
{
if (txt_Search.Text.Trim().Length > 0)
{
Dt_Branch .DefaultView.RowFilter = "name Like '" + txt_Search.Text.Trim().Replace("'", " ") + "%' ";
//GrdBranch.DataSource = Dt_Branch.DefaultView;
//GrdBranch.DataBind();
BindGridView();
}
}
Khargesh RajputPosted Nov 1, 2014, 7:28 AM
and on filter.
use datatable.select()
and bind gridview again