0

这段代码TextBox tx1 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1");

我知道它从 GridView 中的 textbox1 获取数据,并存储在 Textbox 类型中。我还必须使用上面的代码存储哪些其他选项,例如我可以将它存储在 DateTime 类型中吗?

干杯

4

1 回答 1

0

本文介绍了如何使用代码将值存储在数据库中:

sqlcon = new SqlConnection(con);
   sqlcon.Open();
   string sql = "update employee set emp_name='" + 
    tx1.Text + "',emp_address='" + tx2.Text + "',salary='" +
    tx3.Text + "',department='" + ddl.SelectedValue.ToString() 
    + "',maritalstatus='" + rbl.SelectedValue.ToString() + "',Active_status='" 
        + chb.SelectedValue.ToString() + "' where emp_id='" +
   lb.Text + "'";
SqlCommand cmd = new SqlCommand(sql);
   cmd.CommandType = CommandType.Text;
   cmd.Connection = sqlcon;
   cmd.ExecuteNonQuery ();
   GridView1.EditIndex = -1;
   showgrid ();

在受保护的 void GridView1_RowUpdating(对象发送者,GridViewUpdateEventArgs e)

您想将值存储在数据库中吗?

于 2012-09-07T15:25:47.360 回答