Code:
protected void btnDeleteUser_Click(object sender, EventArgs e)
{
string userName = ((TextBox) LoginView1.FindControl("tbUserName")).Text;
if (userName != null)
Membership.DeleteUser(userName, true);
}
May I offer a couple of other suggestions?
1. The DeleteUser method will throw an ArgumentException if userName is an empty string. You need to have a RequiredFieldValidator on tbUserName to eliminate the possibility of that happening.
2. Why do you have so many ObjectDataSources that all represent the exact same object? Just have ONE and put it outside of the LoginView so that all the GridViews can use the same one.