Esempio n. 1
0
    protected void grBPList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        GridView _gridView = (GridView)sender;
        // Get the selected index and the command name
        int    _selectedIndex = int.Parse(e.CommandArgument.ToString());
        string _commandName   = e.CommandName;

        _gridView.SelectedIndex = _selectedIndex;
        switch (_commandName)
        {
        case ("DoubleClick"):
            hfBPID.Value = grBPList.DataKeys[_gridView.SelectedIndex].Values[0].ToString().Trim();
            ddlBenefitHead.SelectedValue = grBPList.DataKeys[_gridView.SelectedIndex].Values[1].ToString().Trim();
            ddlEmpType.SelectedValue     = grBPList.DataKeys[_gridView.SelectedIndex].Values[2].ToString().Trim();
            txtValue.Text                = grBPList.DataKeys[_gridView.SelectedIndex].Values[3].ToString().Trim();
            chkIsPercent.Checked         = grBPList.DataKeys[_gridView.SelectedIndex].Values[4].ToString().Trim() == "Y" ? true : false;
            ddlPercentHead.SelectedValue = grBPList.DataKeys[_gridView.SelectedIndex].Values[5].ToString().Trim();
            btnAdd.Text = "Update";
            break;

        case ("RowDeleting"):
            try
            {
                objOptMgr.DeletePayrollBenefitsPolicyData(grBPList.DataKeys[_gridView.SelectedIndex].Values[0].ToString().Trim());
                hfBPID.Value = "";
                btnAdd.Text  = "Add";
                this.OpenBenefitsPolicyRecord();
                lblMsg.Text = "Recrod deleted successfully";
            }
            catch (Exception ex)
            {
                lblMsg.Text = "Cannot delete the data. Reference data found";
            }

            break;
        }
    }