protected void txtEnddateUpd_DataBinding(object sender, EventArgs e)
    {
        TextBox txt = (TextBox)FvemployeeMaster.FindControl("txtEnddateUpd");

        if (txt.Text != "")
        {
            DateTime s = Convert.ToDateTime(txt.Text);
            txt.Text = s.ToString("dd/MM/yyyy");
        }
    }
 protected void FvemployeeMaster_ItemInserting(object sender, FormViewInsertEventArgs e)
 {
     dtQualification = (DataTable)ViewState["dtQualification"];
     Global.SetFormViewParameters(e.Values, Employee.GetRow());
     InitQualification();
     foreach (ListItem li in ((ListBox)FvemployeeMaster.FindControl("lboxQualificationIns")).Items)
     {
         dtQualification.Rows.Add(li.Value, li.Selected);
     }
     e.Values.Add("dtQualification", dtQualification);
 }
    protected void FvemployeeMaster_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        FormView fv = (FormView)sender;

        Global.SetFormViewParameters(e.NewValues, Employee.GetRow());
        InitQualification();
        foreach (ListItem li in ((ListBox)FvemployeeMaster.FindControl("lboxQualificationUpd")).Items)
        {
            if (li.Selected)
            {
                dtQualification.Rows.Clear();
                DataRow dr = dtQualification.NewRow();
                dr["EmployeeQualiID"] = fv.DataKey["EmployeeID"];
                dr["EmployeeID"]      = fv.DataKey["EmployeeID"];
                dr["QualificationID"] = new Guid(li.Value);
                dtQualification.Rows.Add(dr);
                dtQualification.AcceptChanges();
            }
        }
        e.NewValues.Add("QualificationDetails", dtQualification);
    }
    protected void FvemployeeMaster_DataBound(object sender, EventArgs e)
    {
        if (FvemployeeMaster.CurrentMode == FormViewMode.Edit)
        {
            Employee emp        = new Employee();
            Guid     EmployeeId = (Guid)FvemployeeMaster.DataKey["EmployeeID"];
            ViewState["dtQualification"] = emp.SelectEmpQualificationById(EmployeeId);
            dtQualification = (DataTable)ViewState["dtQualification"];
            ListBox lstbox = (ListBox)FvemployeeMaster.FindControl("lboxQualificationUpd");
            foreach (DataRow dr in dtQualification.Rows)
            {
                ListItem li = lstbox.Items.FindByValue(dr["QualificationID"].ToString());
                if (null != li)
                {
                    li.Selected = true;
                }
            }
        }

        if (FvemployeeMaster.CurrentMode == FormViewMode.ReadOnly)
        {
            Employee emp        = new Employee();
            Guid     EmployeeId = (Guid)FvemployeeMaster.DataKey["EmployeeID"];
            ViewState["dtQualification"] = emp.SelectEmpQualificationById(EmployeeId);
            dtQualification = (DataTable)ViewState["dtQualification"];
            ListBox lstbox = (ListBox)FvemployeeMaster.FindControl("lboxQualificationItm");
            foreach (DataRow dr in dtQualification.Rows)
            {
                ListItem li = lstbox.Items.FindByValue(dr["QualificationID"].ToString());
                if (null != li)
                {
                    li.Selected = true;
                }
            }
        }
    }