Hello All! I am a newb in need of some serious help. I am trying to get my website administration setup by using some different source code. I figured out the database issue I posted a couple of days ago. My current website is a ASP.Net 2.0 starter kit in C#. My web is up and running but I have no control over users or nothing. Sue at http://www.edream.org was kind enough to post some code that should allow us to administer our sites. Problem is, I cannot get past the following:
public class UserManager
{
public static List<Users> GetUsers()
{
using (OleDbConnection connection = new OleDbConnection(ConfigurationManager.ConnectionStrings["ASPNETDB22"].ConnectionString))
{
using (OleDbCommand Mycommand = new OleDbCommand("SELECT aspnet_membership.userid, aspnet_membership.email, aspnet_membership.Isapproved, aspnet_membership.createDate, aspnet_membership.LastLoginDate, aspnet_users.username, aspnet_users.applicationID, aspnet_usersinroles.roleid as UsersInRole from aspnet_membership inner join (aspnet_users left join aspnet_UsersInRoles on aspnet_users.userid=aspnet_usersinroles.userid) on aspnet_membership.userid=aspnet_users.userid ORDER BY aspnet_users.username;", connection))
{
Mycommand.CommandType = CommandType.StoredProcedure;
bool filter = (HttpContext.Current.User.IsInRole("Friends") || HttpContext.Current.User.IsInRole("Administrators"));
Mycommand.Parameters.Add(new OleDbParameter("@makeprivate", filter));
Mycommand.Parameters.Add(new OleDbParameter("@UsersInRole", ""));
connection.Open();
List<Users> list = new List<Users>();
OleDbDataReader reader = Mycommand.ExecuteReader();
{
while (reader.Read())
{
Users temp = new Users(
(int)reader["UserID"],
(int)reader["UserNum"],
(int)reader["UserCount"],
(string)reader["UserName"],
(string)reader["Email"],
(int)reader["UsersInRole"],
(DateTime)reader["CreateDate"],
(DateTime)reader["LastLoginDate"],
(DateTime.Parse(TextBox.Text.ToString(),
(bool)reader["IsApproved"])));
list.Add(temp);
}
}
return list;
}
}
}
I keep getting this error:The name 'textBox1' does not exist in the current context!
All of this is supposed to read and display into a GridView control. There is a textBox there but it has an ID=txtTitle. I have tried changing the the control name(s) but I keep getting this same error. This is the only thing holding me back. I have researched this thing as much as I can on my own and I am reaching out for your help.
Since my website already had a GridView1 control and an ObjectDataSource control, I renamed the ones on this Admin Panel GridView2 and ObjectDataSource2 on this page. I even did a search on my code and changed any references to match what I changed.
Please help me! I am lost here!
Thanks for your time!