protected void grdAccounts_RowCommand(object sender, GridViewCommandEventArgs e) { int id = Convert.ToInt32(e.CommandArgument); LoginBLL bll = new LoginBLL(); if (e.CommandName == "Reset") { string password = string.Empty; do { password = System.Web.Security.Membership.GeneratePassword(10, 3); if (bll.IsValidPasword(password)) { break; } } while (true); bll.ResetPassword(id, password); LogActivity("Password Reset", "User password has been reset", string.Empty); } else if (e.CommandName == "Remove") { bll.RemoveAccount(id); LogActivity("User Deleted", "User has been deleted", string.Empty); } else if (e.CommandName == "ChangeRole") { RadGrid gvr = (RadGrid)((Control)e.CommandSource).NamingContainer; ListItem item = (gvr.FindControl("ddlChangeRole") as DropDownList).SelectedItem; bll.SetRole(id, item.Text); } BindAccounts(); }
protected void grdAccounts_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { //int id = Convert.ToInt32(e.CommandArgument); LoginBLL bll = new LoginBLL(); if (e.CommandName == "Reset") { int id = Convert.ToInt32(e.CommandArgument); string password = string.Empty; do { password = System.Web.Security.Membership.GeneratePassword(10, 3); if (bll.IsValidPasword(password)) { break; } } while (true); bll.ResetPassword(id, password); LogActivity("Password Reset", "User password has been reset", string.Empty); } else if (e.CommandName == "Remove") { int id = Convert.ToInt32(e.CommandArgument); bll.RemoveAccount(id); LogActivity("User Deleted", "User has been deleted", string.Empty); } else if (e.CommandName == "ChangeRole") { if (e.Item is GridDataItem) { int id = Convert.ToInt32(e.CommandArgument); GridDataItem dataItem = (GridDataItem)e.Item; //LinkButton btn = (LinkButton)dataItem.FindControl("LinkButton1"); //btn.BackColor = System.Drawing.Color.Red; DropDownListItem item = (dataItem.FindControl("ddlChangeRole") as RadDropDownList).SelectedItem; bll.SetRole(id, item.Text); } //gvr = (RadGrid)((Control)e.CommandSource).NamingContainer; //DropDownListItem item = (gvr.FindControl("ddlChangeRole") as RadDropDownList).SelectedItem; //bll.SetRole(id, item.Text); } //else if (e.CommandName == "LogOff") //{ // bll.LogOffAccount(Convert.ToInt32(e.CommandArgument)); // LogActivity("User LogOff", "User has been log offed", string.Empty); //} BindAccounts(); }