您目前尚未登陆,请选择【登陆】或【注册
首页->全站代码->WebQuest发布系统源码及文档>>Admin/admin_subjects.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:WebQuest发布系统源码及文档
当前文件:文件类型 WebQuest/Admin/admin_subjects.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using WebQuest; 12public partial class Admin_admin_subjects : System.Web.UI.Page 13{ 14 protected void Page_Load(object sender, EventArgs e) 15 { 16 if (!IsPostBack) 17 { 18 this.GridView1.Attributes.Add("SortExpression", "subjectid"); 19 this.GridView1.Attributes.Add("SortDirection", "desc"); 20 BindSubject(); 21 } 22 23 } 24 25 private void BindSubject() 26 { 27 string SortDirection = this.GridView1.Attributes["SortDirection"].ToString(); 28 string SortExpression = this.GridView1.Attributes["SortExpression"].ToString(); 29 30 31 Subjects myObj = new Subjects(); myObj.Retrieve().Tables[0].DefaultView.Sort = string.Format("{0} {1}", SortExpression, SortDirection); 32 GridView1.DataSource = myObj.Retrieve(); 33 GridView1.DataBind(); 34 } 35 protected void btnDel_Click(object sender, EventArgs e) 36 { 37 38 Subjects myObj = new Subjects(); 39 40 foreach (GridViewRow row in GridView1.Rows) 41 { 42 CheckBox mychk = null; 43 mychk = (CheckBox)row.FindControl("chk"); 44 if (mychk.Checked) 45 { 46 myObj.SubjectId = int.Parse(GridView1.DataKeys[row.DataItemIndex][0].ToString()); 47 myObj.Delete(); 48 } 49 50 } 51 BindSubject(); 52 53 } 54 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) 55 { 56 GridView1.PageIndex = e.NewPageIndex; 57 BindSubject(); 58 } 59 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 60 { 61 switch (e.CommandName) 62 { 63 case "sEdit": Response.Redirect("admin_subjects_edit.aspx?id=" + e.CommandArgument.ToString()); break; 64 65 } 66 67 } 68 protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) 69 { 70 if (e.SortExpression != "") 71 { 72 if (GridView1.PageCount > 0) 73 { 74 //设定排序方向 75 string SortDirection = "desc"; 76 SortDirection = (this.GridView1.Attributes["SortDirection"].ToString() == SortDirection ? "DESC" : "ASC"); 77 this.GridView1.Attributes["SortExpression"] = e.SortExpression; 78 this.GridView1.Attributes["SortDirection"] = SortDirection; 79 //重新绑定数据 80 BindSubject(); 81 } 82 } 83 84 85 86 87 88 } 89} 90
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:WebQuest发布系统源码及文档
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号