index.aspx.cs
上传用户:ah_jiwei
上传日期:2022-07-24
资源大小:54044k
文件大小:2k
源码类别:

数据库编程

开发平台:

Visual C++

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. public partial class teacher_index : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.        // string userId = Session["userId"].ToString();
  17.         string userId = "20080005";
  18.         string teacherlist="";
  19.         string commandString = "select stu_id_num.stu_id,stu_id_num.stu_name from stu_id_num,stu_tea where stu_id_num.stu_id = stu_tea.sut_id and stu_tea.tea_id = " + userId;
  20.         SqlDataSource1.SelectCommand = commandString;
  21.         GridView1.DataBind();
  22.         DataTable dt = new DataTable();
  23.         SqlConnection connection = DB.connect_la();
  24.         connection.Open();
  25.         commandString = "select rep_to_arg.*,stu_name from rep_to_arg,stu_id_num where (stu_id_num.stu_id = rep_to_arg.stu_id)";
  26.        
  27.         SqlCommand cmd = new SqlCommand(commandString, connection);
  28.         SqlDataAdapter sda = new SqlDataAdapter(cmd);
  29.         sda.Fill(dt);
  30.         foreach (DataRow dr in dt.Rows)
  31.         {
  32.             if (!dr["arg_tea_id"].ToString().Contains(userId))
  33.                 dr.Delete();
  34.         }
  35.         GridView3.DataSourceID = "";
  36.         GridView3.DataSource = dt;
  37.         GridView3.DataBind();
  38.         
  39.         
  40.         //sdr.Close();
  41.         connection.Close();
  42.        
  43.     }
  44.     //选择学生
  45.     protected void Button1_Click(object sender, EventArgs e)
  46.     {
  47.         Response.Write("<script>alert('提交成功!');window.location='index.aspx'</script>");
  48.     }
  49. }