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 or i dont know if it possible to bind three of those DDLs into one method as below method as they are doing the same job?
-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", ""));
- }
-
-
- }