ListAllUsers.aspx.cs
资源名称:SunShine.rar [点击查看]
上传用户:tjxpgg
上传日期:2017-05-14
资源大小:2244k
文件大小:3k
源码类别:
SilverLight
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class ListAllUsers : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- bind();
- }
- }
- public void bind()
- {
- this.GridView1.DataSource = DBHelp.Select("select * from vw_Users");
- this.GridView1.DataBind();
- }
- //protected void ChangState(object sender, EventArgs e)
- //{
- // LinkButton link = sender as LinkButton;
- // int rowsIndex = Convert.ToInt32(link.CommandArgument);
- // string name = (this.GridView1.Rows[rowsIndex].Cells[8].FindControl("LinkButton1") as LinkButton).Text;
- // Response.Write(name);
- //}
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- //GridViewRow drv = e.Row;
- //switch (drv.RowType)
- //{
- // case DataControlRowType.DataRow:
- // LinkButton link1 = drv.FindControl("LinkButton1") as LinkButton;
- // if (link1 != null)
- // {
- // link1.CommandArgument = drv.RowIndex.ToString();
- // }
- // break;
- //}
- }
- protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
- {
- if (e.CommandName =="Click")
- {
- int type = Convert.ToInt32(e.CommandArgument);
- DataTable dt= DBHelp.Select("select * from users where id=" + type + "");
- int ty=Convert.ToInt32( dt.Rows[0]["userstateid"]);
- if (ty == 1)
- {
- DBHelp.Update("update users set userstateid=" + 2 + " where id="+type+"");
- bind();
- }
- else
- {
- DBHelp.Update("update users set userstateid=" + 1 + " where id ="+type+"");
- bind();
- }
- }
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- for(int i=0;i<this.GridView1.Rows.Count;i++)
- {
- if ((this.GridView1.Rows[i].Cells[1].FindControl("CheckBox1") as CheckBox).Checked)
- {
- int id = Convert.ToInt32((this.GridView1.Rows[i].Cells[8].FindControl("LinkButton1") as LinkButton).CommandArgument);
- DBHelp.Update("update users set userstateid=" + 1 + " where id=" + id + "");
- }
- }
- bind();
- }
- protected void Button2_Click(object sender, EventArgs e)
- {
- for (int i = 0; i < this.GridView1.Rows.Count; i++)
- {
- if ((this.GridView1.Rows[i].Cells[1].FindControl("CheckBox1") as CheckBox).Checked)
- {
- int id = Convert.ToInt32((this.GridView1.Rows[i].Cells[8].FindControl("LinkButton1") as LinkButton).CommandArgument);
- DBHelp.Update("update users set userstateid=" + 2 + " where id=" + id + "");
- }
- }
- bind();
- }
- }