此代码TextBox tx1 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1");
我知道它从GridView中的textbox1中获取数据,并以Textbox类型存储。我需要使用上面的代码存储哪些其他选项,例如我可以将它存储在DateTime类型中吗?
干杯
答案 0 :(得分: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 ();
in protected void GridView1_RowUpdating(object sender,GridViewUpdateEventArgs e)
您要将值存储在数据库中吗?