How to filter data from gridview on demand by using datasour
I have binded the gridview by using datasource then how to filter from it by perticular selecting couloumn value? and how to paging by using dropdwonlist?
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.
Santhakumar MunuswamyPosted Apr 19, 2015, 4:16 PM
Refer this below link
http://san2debug.net/post/How-to-Gridview-Header-Filtering-in-Aspnet.aspx
Pradeep ShetPosted Apr 19, 2015, 4:08 PM
http://www.codeproject.com/Articles/67520/GridView-Paging-and-Sorting
dawood abbasPosted Apr 16, 2015, 2:10 AM
Actually I stored in viewstate then can filter on it but cant apply paging. so I bound data by using 'SqlDatasource' in aspx page not by dataset so I thought its easy to paging from this but still in searching it.
Pradeep ShetPosted Apr 16, 2015, 1:50 AM
1) Once data is bound store that dataset in a ViewState["data"]
2) Based on total row count / 10 (page size), fill the dropdown from 1 to result received by division
3) On PageChangeIndexChnaged, write a logic for getting partiuclar set of records from ViewState and bind the gridview again
4)For search bind all columnNames in the dropdownlist and one textbox for search text
ddlSearchColumns.DataSource = ds.Tables[0].Columns
ddlSearchColumns.DataBind()
5)On search click,
DataSet ds = (DataSet)ViewState["data"];
DataRow[] drs = ds.Tables[0].Select(ddlSearchColumns.SelectedValue + "='" + txtSearch.Text + "'");
You will get the DataRow array of result, convert it back to datatable
DataTable dt1 = dr.CopyToDataTable();
Then bind it back to gridview
Plz mark it as answered if this solves your problem