mardi 16 février 2016

How to refactor the code so one method for the two web forms

If i have two web forms like this :

public partial class frm_createVac : System.Web.UI.Page

public partial class frm_editVac : System.Web.UI.Page

and both of pages have the following same method :


 private void FillVacations()
        {
            DataTable dt = DAL.Vacation.GetVacationTypes();
            ddl_vac_type.Items.Clear();
            ddl_vac_type.DataSource = dt;
            ddl_vac_type.DataTextField = "vac_name";
            ddl_vac_type.DataValueField = "vac_code";
            ddl_vac_type.DataBind();

            ListItem item = new ListItem("-SELECT-", "-1");
            ddl_vac_type.Items.Insert(0, item);
        }

How to refactor my code so that i have one method for both pages?

Aucun commentaire:

Enregistrer un commentaire