您目前尚未登陆,请选择【登陆】或【注册
首页->行政办公->多功能在线考试系统改进版源码>>Web/FillBlankManage.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:多功能在线考试系统改进版源码
当前文件:文件类型 OnLineExamUpdate/Web/FillBlankManage.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 OnLineExam.BusinessLogicLayer; 12 13public partial class Web_FillBlankManage : System.Web.UI.Page 14{ 15 protected void Page_Load(object sender, EventArgs e) 16 { 17 if (!IsPostBack) 18 { 19 string loginName = Session["userID"].ToString(); 20 Users user = new Users(); 21 user.LoadData(loginName); 22 labUser.Text = user.UserName; 23 InitDDLData(); //初始化考试科目 24 } 25 } 26 //初始化考试科目 27 protected void InitDDLData() 28 { 29 Course course = new Course(); //创建考试科目对象 30 DataSet ds = course.QueryCourse(); //查询考试科目信息 31 ddlCourse.DataSource = ds; //指名考试科目列表框数据源 32 ddlCourse.DataTextField = "Name"; //DataTextField显示Name字段值 33 ddlCourse.DataValueField = "ID"; //DataValueField显示ID字段值 34 ddlCourse.DataBind(); //绑定数据 35 GridViewBind(); 36 } 37 //显示选择科目的填空题 38 protected void ddlCourse_SelectedIndexChanged(object sender, EventArgs e) 39 { 40 FillBlankProblem fillblankproblem = new FillBlankProblem(); //创建填空题对象 41 DataSet ds = fillblankproblem.QueryFillBlankProblem(int.Parse(ddlCourse.SelectedValue));//根据考试科目查询填空题信息 42 GridView1.DataSource = ds.Tables[0].DefaultView; //为GridView控件指名数据源 43 GridView1.DataBind(); //绑定数据 44 } 45 //删除试题事件 46 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) 47 { 48 FillBlankProblem fillblankproblem = new FillBlankProblem(); //创建填空题对象 49 int ID = int.Parse(GridView1.DataKeys[e.RowIndex].Values[0].ToString()); //取出要删除记录的主键值 50 if (fillblankproblem.DeleteByProc(ID)) 51 { 52 Response.Write("<script language=javascript>alert('成功删除试题!')</script>"); 53 } 54 else 55 { 56 Response.Write("<script language=javascript>alert('删除试题失败!')</script>"); 57 } 58 GridViewBind();//为GridView重新绑定数据 59 GridView1.EditIndex = -1; 60 } 61 //显示选择科目的填空题 62 protected void ddlCourse_SelectedIndexChanged1(object sender, EventArgs e) 63 { 64 GridViewBind();//为GridView绑定数据 65 } 66 protected void GridViewBind() 67 { 68 FillBlankProblem fillblankproblem = new FillBlankProblem(); //创建填空题对象 69 DataSet ds = fillblankproblem.QueryFillBlankProblem(int.Parse(ddlCourse.SelectedValue));//根据考试科目查询填空题信息 70 GridView1.DataSource = ds.Tables[0].DefaultView; //为GridView控件指名数据源 71 GridView1.DataBind(); //绑定数据 72 } 73 //删除多条记录 74 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) 75 { 76 FillBlankProblem fill = new FillBlankProblem();//创建FillBlankProblem对象 77 foreach (GridViewRow dr in GridView1.Rows)//对GridView中的每一行进行判断 78 { 79 if (((CheckBox)dr.FindControl("xuanze")).Checked)//如果选择了进行删除 80 { 81 int ID = int.Parse(((Label)dr.FindControl("Label1")).Text); 82 fill.ID = ID; 83 fill.DeleteByProc(ID); 84 } 85 } 86 } 87 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) 88 { 89 GridView1.PageIndex = e.NewPageIndex; 90 GridViewBind();//重新绑定数据 91 } 92 93 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 94 { 95 if (e.Row.RowType == DataControlRowType.DataRow) 96 { 97 e.Row.Cells[2].ToolTip = e.Row.Cells[2].Text; 98 e.Row.Cells[3].ToolTip = e.Row.Cells[3].Text; 99 if ((e.Row.Cells[2].Text).Length > 20) 100 { 101 e.Row.Cells[2].Text = (e.Row.Cells[2].Text).Substring(0, 20) + "..."; 102 } 103 if ((e.Row.Cells[3].Text).Length > 20) 104 { 105 e.Row.Cells[3].Text = (e.Row.Cells[3].Text).Substring(0, 20) + "..."; 106 } 107 if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate) 108 { 109 ((LinkButton)e.Row.Cells[5].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除吗?')"); 110 } 111 112 } 113 int i; 114 //执行循环,保证每条数据都可以更新 115 for (i = 0; i < GridView1.Rows.Count; i++) 116 { 117 //首先判断是否是数据行 118 if (e.Row.RowType == DataControlRowType.DataRow) 119 { 120 //当鼠标停留时更改背景色 121 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='Aqua'"); 122 //当鼠标移开时还原背景色 123 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c"); 124 } 125 } 126 } 127} 128
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:多功能在线考试系统改进版源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号