日期:2014-05-16 浏览次数:20767 次
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
namespace Lb_news
{
/// <summary>
/// admin_user 的摘要说明。
/// </summary>
public partial class admin_user : System.Web.UI.Page
{
protected Conn ds2=new Conn();
protected string Lb_Grade;
protected string Lb_Grade2;
protected OleDbDataReader rd;
protected DataSet ds;
protected string strSql;
protected void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
ds2.CheckCookies(3);
if(!Page.IsPostBack)
{
LbNewsUser("def");
}
}
private void LbNewsUser(string ShowType)
{
if (ShowType=="def")
{
strSql="select * from Lb_Admin";
}
else
{
string SeaName=Request["keyword"];
strSql="select * from Lb_Admin where A_Name like '%"+SeaName+"%'";
}
try
{
ds2.DBopen();
ds=ds2.CreateDataSet(strSql,"Lb_User");
LbNews_User.DataSource = ds;
LbNews_User.DataBind();
}
catch(System.Data.OleDb.OleDbException e)
{
Response.Write (e.ToString());
}
finally
{
ds2.DBclose();
}
}
public string Lb_ChageName(object a)
{
int grade=ds2.ChangeToInt(a.ToString());
switch(grade)
{
case 1:
Lb_Grade="输入员";
break;
case 2:
Lb_Grade="审核员";
break;
case 3:
Lb_Grade="管理员";
break;
}
return Lb_Grade;
}
public void BindGrade()
{
ListItem grade1=new ListItem("输入员","1");
ListItem grade2=new ListItem("审核员","2");
ListItem grade3=new ListItem("审核员","3");
LbNews_Grade.Items.Add(grade1); //当前上下文中不存在名称“LbNews_Grade”
LbNews_Grade.Items.Add(grade2);
LbNews_Grade.Items.Add(grade3);
}
<EditItemTemplate>
<asp:DropDownList ID="LbNews_Grade" Runat="server">
<asp:ListItem Value="1">输入员</asp:ListItem>
<asp:ListItem Value="2">审核员</asp:ListItem>
<asp:ListItem Value="3">管理员</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>