protected void Page_Load(object sender, EventArgs e) { DataAccess.GetData GD = new DataAccess.GetData(); DataTable xx = GD.GetDataTable("select * from grfc"); this.DataList1.DataSource = xx; this.DataList1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { for (int i = 0; i < GridView1.Rows.Count; i++) { //var txt = (TextBox)GridView1.Rows[i].FindControl("TextBox1"); //var txt3 = (TextBox)GridView1.Rows[i].FindControl("TextBox3"); //var txt2 = (TextBox)(GridView1.Rows[i].FindControl("TextBox2")); string txt = ((TextBox)GridView1.Rows[i].FindControl("TextBox1")).Text; string txt3 = ((TextBox)GridView1.Rows[i].FindControl("TextBox3")).Text; string txt2 = ((TextBox)GridView1.Rows[i].FindControl("TextBox2")).Text; //if (txt == null) //{ // continue; // }" + Session["LoginStudentXH"] + " " + Session["MXN"].ToString() + " DataAccess.GetData GD = new DataAccess.GetData(); DataTable xx = GD.GetDataTable("insert into Student_LHPF(Sno,XN,XID,DF,DFYJ) VALUES ('" + Session["LoginUserXH"] + "','" + Session["MXN"].ToString() + "','" + txt3 + "','" + txt + "','" + txt2 + "')"); // //SqlConnection con = new SqlConnection("Data Source=HCW4GXJWFCWVBJ9\\SQLEXPRESS;Initial Catalog=ZHLH;Integrated Security=True"); //var sno = Session["LoginUserXH"]; //?? "201101030275"; // var val = txt.Text; // var val1 = txt3.Text; // var val2 = txt2.Text; // // string xn = Session["MXN"].ToString(); // var insertSql = string.Format("insert into Student_LHPF(Sno,XN,XID,DF,DFYJ) VALUES ('" + Session["LoginUserXH"] + " ','" + Session["MXN"].ToString() + "','" + val1 + "','{3}','{4}')", sno, val1, val, val2); //SqlCommand com = new SqlCommand(insertSql);// "insert into LHPF(Sno,XN,XID,DF,DFYJ) VALUES ((select XID from XMB where XMMC="+ +"),'" + txt + "','" + txt3 + "') ", con); SqlCommand com = new SqlCommand(); com.Connection = cn; try { { cn.Open(); int ret = com.ExecuteNonQuery(); //con.Close(); if (ret <= 0) { ClientScript.RegisterStartupScript(this.GetType(), "", "alert('提交数据失败!')"); } else { ClientScript.RegisterStartupScript(this.GetType(), "", "alert('提交数据成功!')"); } } } catch (Exception ex) { // ClientScript.RegisterStartupScript(this.GetType(), "", "alert('插入数据失败! 详情:" + ex.Message + "')"); } } }
private void RelyInfo(string dd) { DataAccess.GetData GD = new DataAccess.GetData(); DataTable xx = GD.GetDataTable("select * from Rely where Guestid='"+dd+"'"); this.GridView1.DataSource = xx; this.GridView1.DataBind(); this.GridView1.DataSource = xx; this.GridView1.DataBind(); }
private void Showdata() { DataAccess.GetData GD = new DataAccess.GetData(); DataTable xx = GD.GetDataTable("select * from Guest order by ID desc"); this.GridView1.DataSource = xx; this.GridView1.DataBind(); }
private void InfoData( string id) { DataAccess.GetData GD = new DataAccess.GetData(); DataTable xx = GD.GetDataTable("select * from Guest where id="+id+""); this.GridView1.DataSource = xx; this.GridView1.DataBind(); this.Label1.Text = "留言内容:" +xx.Rows[0][1].ToString(); }