Last post Feb 08, 2016 12:52 PM by bbcompent1
Feb 05, 2016 10:52 AM|ramiwahdan|LINK
I have this code but it is not working. can someone help
protected void BindGridviewData()
DataTable dTable = new DataTable();
foreach (MembershipUser u in Membership.GetAllUsers())
DataRow dRow = dTable.NewRow();
dRow = false;
dRow = u.UserName;
string roles = Roles.GetRolesForUser(u.UserName);
dRow = roles.Contains("Admin") ? true : false;
dRow = roles.Contains("Controller") ? true : false;
dRow = roles.Contains("User") ? true : false;
GridView1.DataSource = dTable;
protected void cmdUpdateRole_Click(object sender, EventArgs e)
foreach (GridViewRow row in GridView1.Rows)
string username = row.Cells.Text;
CheckBox chkAdmin = (CheckBox)row.Cells.Controls;
CheckBox chkUser = (CheckBox)row.Cells.Controls;
CheckBox chkgen = (CheckBox)row.Cells.Controls;
List<string> roles=new List<string>();
if (Roles.GetRolesForUser(username).Length > 0)
if (roles.Count > 0)
// GridView1.Visible = false;
// cmdUpdateRole.Visible = false;
// DropDownList1.SelectedIndex = 0;
Feb 05, 2016 01:31 PM|bbcompent1|LINK
Can you provide a bit more detail about what you mean by "not working"? That is the same as going to the mechanic saying my car is broke but not telling them what specifically is broken.
Feb 05, 2016 02:12 PM|ramiwahdan|LINK
Thanks for the reply,
I mean it doesn't do anything and the gridview is refreshed (back to original), no updates happens based on selection.
Feb 05, 2016 04:23 PM|bbcompent1|LINK
Ok, let me replicate your project on my end and I'll see what is going on. Have you tried setting a breakpoint in the code and stepping through it to see what the code does? Maybe the event handler is not getting hit.
Feb 05, 2016 04:24 PM|bbcompent1|LINK
Can you post the source from the aspx page? That would save me some time.
Feb 07, 2016 05:35 AM|ramiwahdan|LINK
i was doing something wrong with if(!ispostback).
Feb 08, 2016 12:52 PM|bbcompent1|LINK
See, that is why we ask for code :) You could have saved yourself hours of agony because we probably would have seen that problem right off.