Hi, I have a GirdView listening all Users active in my system using ASP:NET Membership. I would like have a CheckBox that could be SELECTED or NOT depending if a specific user is APPROVED or not. With event handler RowDataBound, my script does not work. Any idea to selected the CheckBox in the appropirate case?
Thanks for your time :-)
protected void uxUserListDisplayer_RowDataBound(object sender, GridViewRowEventArgs e)
{
// Check or Uncheck a CheckBox depending if user is Approved
switch (e.Row.RowType)
{
// In case type of row is DataRow (a data row of GridView)
case DataControlRowType.DataRow:
// Create an object of type MembershipUser for row bounded (Users)
MembershipUser myUser = (MembershipUser)e.Row.DataItem;
// Find out the edit button "uxLinkEditButton" and create an object for it
LinkButton editButton = (LinkButton)e.Row.FindControl("uxLinkEditButton");
// Find out the checkbox "uxActiveCheckBoxSelector" and create an object for it
CheckBox activeCheckBox = (CheckBox)e.Row.FindControl("uxActiveCheckBoxSelector");
// Check if the Object type MembershipUser for a User is approved or not
if (myUser.IsApproved == true)
{
activeCheckBox.Checked = true; // Checkbox is checked
}
else
{
activeCheckBox.Checked = false; // Checkbox is unchecked
}
break;
}
}