Hi
I trying my best to make my web application faster as much as i can, so one of what i am looking is reducing the codes into each page. So i have three DDL as mention below they do the same job to bind the DDL's depending on cookie value. So how i can create a class and use it for to bind all DDL's
-StateHPDDL
-BizstateHPFilterDDL
-filterstathpjob
the code used for each DDL in page_load is as below
if (!IsPostBack)
{
if (cookie["Location"] == null)
{
DataTable filterstathpAdsDT = new DataTable();
using (SqlConnection filterstathpAdsCon = new SqlConnection(cs))
{
SqlCommand filterstathpAdsCMD = new SqlCommand("SELECT State FROM State WHERE Country = @Location", filterstathpAdsCon);
var Location = cookie.Value;
filterstathpAdsCMD.Parameters.AddWithValue("@Location", Location);
SqlDataAdapter filterstathpAdsAP = new SqlDataAdapter();
filterstathpAdsAP.SelectCommand = filterstathpAdsCMD;
filterstathpAdsAP.Fill(filterstathpAdsDT);
StateHPDDL.DataSource = filterstathpAdsDT;
StateHPDDL.DataTextField = "State";
StateHPDDL.DataBind();
}
StateHPDDL.Items.Insert(0, new ListItem("Select Province", ""));
}
}
Please i will appreciate if you explain step by step that make make it more clear for me to understand and follow your steps