Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hii i am newbie to .net programming,i am trying to filter a gridview, using logical conditions that were filled dropdownlist

eg: select * from emp where salary < 10000 (i filled "<" operator in dropdownlist)
using the above query i want to display emp names less than 10000 in asp.net
Posted
Comments
Rockstar_ 30-May-13 6:53am    
Can i have ur code?
Rockstar_ 30-May-13 6:53am    
What u do is , write if condition for lessthan and greaterthan

1 solution

You can try this..

C#
string query = "select * from emp where salary < 1000";
cmd = new SqlCommand(query,con);
da = new SqlDataAdapter(cmd);
dt = new DataTable();
da.Fill(dt);
dropdownList1.DataSource = dt;
dropdownList1.DataValueField = "empName";
dropdownList1.DataTextField= "empName";
dropdownList1.DataBind();
 
Share this answer
 
Comments
anudeep varikoti 30-May-13 9:09am    
****i just want my logical conditions to be applied from dropdownlist only****.

i have a database with empnames,sal nd empid,
when i just wish to filter my db with logical conditions(say,.sal > 10000) i want to display those filtered values to my gridview..
Dharmendra-18 31-May-13 5:32am    
use like this

gridview1.DataSource=dt;
gridview1.DataBind();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900