Select Only Titles Containing The Text:
form> The following is the script:
String gstrsortorder; // to hold the sort order string gstrfindtext; // to hold the filter expression
void Page_Load (Object sender, EventArgs e) {if (Page.IsPostBack) {// set the value to be used for the RowFilter on the DataView gstrFindText = "Title LIKE '*" txtFindText.Text "*'";} Else {// set the default value for the sort string and filter text box gstrsortorder = "isbn"; txtFindText.text = "asp";
// recreate the data set and bind to the datagrid control binddatagrid ();
Void Sortrows (Object Objsender, DataGridsortCommandeventArgs Objargs) {// Runs When the Column Headings in The DataGrid Are Clicked
// get the column Heading That Was Clicked // Get Sorted Core Values Gstrsortorder = Objargs.Sortexpression.toString ();
// recreate the data set and bind to the DataGrid control BindDataGrid ();} void BindDataGrid () {// get connection string from ../global/connect-strings.ascx user control string strConnect = ctlConnectStrings.OLEDBConnectionString;
// Create a SQL Statement TO SELECT SOME ROWS from The Database String Strselect = "Select * from booklist";
// Create a variable to hold an instance of a dataview object dataview objdataview;
// Get DataView from get-dataview-control.ascx user control objDataview = CTLDataView.getDataView (strconnect, strselect);
IF (ObjDataView == Null) return;
// sort the rows in the dataview inTo the specified order // sort objDataView.sort = gstrsortorder;
// select the rows in the dataview That Match The Filter // Settings ObjdataView.RowFilter = GSTRFINDTEXT;
// set the datasource property of the datalist mydatagrid.datasource = objdataview;
// and bind the control to the data mydatagrid.database ();
script> Note: DataGridSortCommandeventArgs Objargsgstrsortorder = Objargs.Sortexpression.toDataView.Sort = gstrsortorder; objDataView.rowfilter = gstrfindText;