This is a migrated thread and some comments may be shown as answers.

[Solved] Grid filtering after button clicked

1 Answer 134 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sabarishbabu
Top achievements
Rank 1
sabarishbabu asked on 16 Jul 2009, 10:02 AM
Grid filtering after button clicked
Hi,
1. I am using RadGrid, Bind data from database.
2. I want to filter my grid data, based on dates (from and to).
3. I have two text box From date, Todate field and one Go button
4. Select the dates  and hit the go button, I want the Grid to show the data between the selected two dates.
5. Any idea let me know.

Thanks
Sabarish

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Jul 2009, 12:56 PM
Hello Sabarish,

I suppose that you have the textboxes and the button outside the grid. If that is the case, you can try setting the FilterExpression as shown below:
c#:
 protected void btnGo_Click(object sender, EventArgs e) 
    { 
           string filterExpression;             
           filterExpression = "([DateColumnDataField] >= '"+ TextBox1.Text+"') AND ([DateColumnDataField] <= '"+ TextBox2.Text+"')"
             
           RadGrid1.MasterTableView.FilterExpression = filterExpression; 
           RadGrid1.MasterTableView.Rebind(); 
    
    } 

Thanks
Princy.
Tags
Grid
Asked by
sabarishbabu
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or