For, this type of things. Better to take the values in the textbox and rebind the data in the database, but with the where condition in the sql query. And in the resultant Dataset only the required search results will be there, later bind the resultant dataset to the datagrid.

i use this query to search data from column 1..

LIKE ? + '%'

can i use this 2 both column ?

you can't use the LIKE keyword for filtering the values in the Database for both columns, because they both have different values of different datatypes. Use only where keyword for the filter.

I you use LIKE keyword for two different columns in a table of the database, then conflicts occur at that time, you will get wrong result. to search data in datagrid by date only??

what query i need ??

Edited 5 Years Ago by arezz09: n/a

Ok, if you want to do that follow the code below.

Dim dView As New DataView
                dView = Session.Item("ReportDS")
                Session.Item("ReportDS") = ""
                dView.RowFilter = strCondition.ToString
                Session.Item("ReportDS") = dView
                CMSgrid.DataSource = dView

Edited 5 Years Ago by Saikalyankumar: Modified the Coding

how to declare this...

("ReportDS") are this column..

strCondition is an string in which you have to give the Condition what you want to filter i.e., for ex

strCondition="Empno =" & empno & "and" & "Empname ='" & empname & "'"

, CMSgrid here means the gridview name ok, give the gridview id which you have given at that place, and the


is nothing but the session variable. When you bind the values at first time from the database, pass the dataset you have retrieved into this session variable for sorting the records.

Edited 5 Years Ago by Saikalyankumar: Edited the Description.

Hello, "ReportDS" is not column name its session name ok. The combined


is called as Session variable, you can use any name as giving for a session variable. And dont seperate the "ReportDS" and Session ok.

This article has been dead for over six months. Start a new discussion instead.