forum.venkateswarlu.net
      Register      Login
.net

2 replies to this topic

Hari Prasath #1
Member
28 Points
Posted on 03 Jan 2012 08:55 PM IST hi friends
how to useing where condition in data gridview
send me for an codeing formating.
thanks
Yours
hari 
Dot Net     829 views     Reply to this topic
Jahnavi N #2
Member
164 Points
Replied on 04 Jan 2012 11:36 AM IST Hi,

To use where condition in gridview, it is better to apply filter for the table which you want to bind the gridview.

First create a dataview for your datatable and then apply row filter finally bind your grid with dataview.

DataView has property RowFilter which is similar to where condition.

DatatTable dt=Your Data Table;
DataView dv = dt.DefaultView;

dv.RowFilter = "empid = 8";
dv.RowFilter = "EmpName = 'Pankaj'" ;
dv.RowFilter = "Date = #12/08/2000#" ;
dv.RowFilter = "Date>=" + "#" + startdate + "#" + "And Date <=" + "#" + enddate + "#";

GridView1.DataSource = dv;
GridView1.DataBind();

Hope this will help you. 
Reply to this topic
Hari Prasath #3
Member
28 Points
Replied on 05 Jan 2012 11:57 PM IST hi friend
Thanks you responseable your answer... 
Reply to this topic