I am working on an online project ......
i have two links on one of the page..... say home page.... having two links One Say Shirts and Other Say Casual Shirts....
So when user click on Shirts he will be shown all Shirts from Shirts Table for men and when he select Casual Shirts he will be shownall Casual Shirts from Shirts table for men.....
I am using following code...
<a href="Shirts.aspx?For=Men">Shirts</a>
<a href="Shirts.aspx?For=Men&Type=CasualShirts">Casual Shirts</a>
So when Shirts.aspx is loded i have written following code in page_Load event....
string Type= Request.QueryString["Type"];
string For = Request.QueryString["For"];
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=HP-HP\\SQLEXPRESS;Initial Catalog=OnlineShop;User ID=sa;password=rane@1234";
con.Open();
SqlCommand cmd = new SqlCommand("Select * from Shirts where ForMW='"+For+"' and Type='"+Type+"'", con);
SqlDataReader dr = cmd.ExecuteReader();
dt = new DataTable();
dt.Load(dr);
DataList1.DataSourceID = null;
DataList1.DataSource = dt;
DataList1.DataBind();
Now the problem is that i cannot give Both query ie...
ForMW and Type take from QueryString
string Type= Request.QueryString["Type"];
string For = Request.QueryString["For"];
1.Select * from Shirts where ForMW='"+For+"' becomes
1.Select * from Shirts where ForMW='Men'
2.Select * from Shirts where ForMW='"+For+"' and Type='"+Type+"'" becomes
2.Select * from Shirts where ForMW='Men' and Type='CasualShirts'