protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlRoles.DataSource = rBLL.GetAvailableRoles(); ddlRoles.DataTextField = "RoleName"; ddlRoles.DataValueField = "RoleID"; ddlRoles.DataBind(); if (Request.QueryString["id"] == null) { btnCreate.Visible = true; btnUpdate.Visible = false; } else { int id = int.Parse(Request.QueryString["id"].ToString()); var obj = uBLL.GetUserById(id); hdUserID.Value = id.ToString(); txtFullName.Text = obj.FullName; txtUsername.Text = obj.Username; txtAddress.Text = obj.Address; txtPhone.Text = obj.Phone; ddlRoles.SelectedValue = obj.RoleID.ToString(); ddlStatus.SelectedValue = obj.Status == true ? "1" : "0"; btnCreate.Visible = false; btnUpdate.Visible = true; } } }