日期:2014-05-17 浏览次数:21030 次
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridViewBind();
}
}
protected void GridViewBind()
{
int flag=1;
if ((string)Session["teachersid"] == "admin")
{
GridView1.DataSource = UsersManager.BllGetAllUsersInfo(flag);
}
else
{
flag = 0;
GridView1.DataSource = UsersManager.BllGetAllUsersInfo(flag);
}
GridView1.DataBind();
}
/// <summary>
/// 获取所有用户的信息
/// </summary>
/// <returns></returns>
public static List<UsersModel> GetAllUsersInfo()
{
string sqlstr = "select * from users order by [identity]";
SqlConnection conn = new SqlConnection(connstr);
List<UsersModel> list = new List<UsersModel>();
try
{
using (conn)
{
conn.Open();
SqlCommand cmd = new SqlCommand(sqlstr, conn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
&nb