Example #1
0
    protected void dgLocation_ItemCommand(object source, DataGridCommandEventArgs e)
    {
        if (e.CommandName == "Edit")
        {
            dtLCM = GetLocationCode(e.Item.Cells[0].Text.ToString().Trim());
            FillFormControls(dtLCM);
            hidMode.Value = "Update";

            btnSave.Visible = (LocationMasterSecurity != "") ? true : false;
            EnableAddMode(false);
            UpdatePanels();
            ToggleLink(true);
            ScriptManager.RegisterClientScriptBlock(txtAddress1, txtAddress1.GetType(), "focud", "document.getElementById('" + txtAddress1.ClientID + "').select();document.getElementById('" + txtAddress1.ClientID + "').focus();", true);
        }
        if (e.CommandName == "Delete")
        {
            try
            {
                locationMaster.DeleteLocationMaster(e.CommandArgument.ToString().Trim());
                BindDataGrid();
                ClearControls();
                hidMode.Value = "New";
                EnableAddMode(true);
                btnSave.Visible = false;
                DisplaStatusMessage(deleteMessage, "success");
            }
            catch (Exception ex)
            {
                DisplaStatusMessage(ex.Message.ToString(), "Fail");
            }
            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "Focus", "document.getElementById('div-datagrid').scrollTop='" + hidScrollTop.Value + "';", true);
            UpdatePanels();
        }
    }