protected void Page_Load(object sender, EventArgs e)
{
int j = Convert.ToInt32(Request.QueryString["Cat_Id"]);
int i = Convert.ToInt32(Request.QueryString["Sub_Cat_Id"]);
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\site\SamsungClassifieds\App_Data\Dorknozzle.mdf;Integrated Security=True;User Instance=True");
con.Open();
SqlDataAdapter cmd = new SqlDataAdapter("SELECT AD_ID,AD_TITLE, AD_DESC, AD_IMG, AD_PRICE, AD_NO, SUB_CAT_DESC, CAT_DESC, SELLER_NAME, SELLER_MOB_NO, SELLER_EMAIL_ID, SELLER_DEP, SELLER_FLOOR,DATE FROM AD_DETAIL_V WHERE (DATE >= { fn CURDATE() }) and BUY_SELL_ID='1' and DELETED_AD = '0' AND SUB_CAT_ID= " + i + "AND CAT_ID =" + j, con);
DataSet ds = new DataSet();
cmd.Fill(ds);
gvImages.DataSource = ds;
gvImages.DataBind();
}
i and j are the cat_id & Sub_cat_ID of the result page i want it to redirect to home page if the cat_ID & Sub_Cat_doesn't exists.
Example - http://localhost:50476/SamsungClassifieds/Results.aspx?Cat_Id=4&Sub_Cat_Id=10000
it will redirect to homepage.