1. ViewStates
public DataTable dtBatchDetails { get { return (DataTable)ViewState["dtBatchDetails"]; } set { ViewState["dtBatchDetails"] = value; } }
2. Page Load
if ((Session["intUserId"] == null)) { Response.Redirect("~/Login.aspx"); } else { isControlPermission = false; this.UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None;
string PageName = Path.GetFileNameWithoutExtension(Page.AppRelativeVirtualPath); //int a = Convert.ToInt32(Session["intUserId"]); dtScreenList = Search.FGetAuthorizedPages(Convert.ToInt32(Session["intUserId"]), PageName);
if (dtScreenList.Rows.Count > 0 && Convert.ToBoolean(dtScreenList.Rows[0][2].ToString()) == true) { if (!IsPostBack) { ClearControls();
// DisableButtons(); EnableControls(false); Session["SearchPopup"] = false; GetAccessRights();
} else { if (Session["SearchPopup"] != null) { SearchPopup = (bool)(Session["SearchPopup"]); if (SearchPopup != false) { MyMPE.Show();
} else { MyMPE.Hide(); } } vAdSearchParaList = new List<SearchParametors>(); } } else { Response.Redirect("~/WebForms/Administration/NoPermission.aspx"); }
}3.Clear Controls
private void ClearControls() { dtBatchDetails = null; gvJobs.DataSource = null; gvJobs.DataBind(); createCompoundDataTable(); CompoundGridAddEmptyRow(1); ImageUploted = null; ImageName = null; Image1.ImageUrl = null; FileUploader = null;
List<TextBox> allControls = new List<TextBox>(); GetControlList<TextBox>(Page.Controls, allControls); foreach (var childControl in allControls) { childControl.Text = string.Empty; }
List<RadioButton> allControls2 = new List<RadioButton>(); GetControlList<RadioButton>(Page.Controls, allControls2); foreach (var childControl in allControls2) { childControl.Checked = false; }
List<Label> allControls3 = new List<Label>(); GetControlList<Label>(Page.Controls, allControls3); foreach (var childControl in allControls3) { childControl.Text = string.Empty; }
StatusId = 0; RequestTypeId = 0;PriorityId = 0;RequestId = 0;
}
4. Help Grid Row Command
protected void gvHelp_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") {
int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = gvHelp.Rows[index]; if (Session["Help"].ToString() == "CCDEPT") { txtCCDept.Text = selectedRow.Cells[2].Text.ToString(); lblCCdeptName.Text = selectedRow.Cells[1].Text.ToString(); lblCCdeptId.Text = selectedRow.Cells[3].Text.ToString(); lblCCEmail.Text = selectedRow.Cells[4].Text.ToString(); } } }