我写了以下代码。
我的第一个 orderid 有进程 1 和进程 2 的记录,但我的 2nd orderid 只记录了进程 1。
当我在选择 orderid 1 后选择 orderid 2 时,它会保留进程 2 文本框中的 orderid 1 的值。我希望那个文本框是空白的
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DbConnect objdbc = new DbConnect();
SqlConnection con = objdbc.openConnection();
SqlCommand cmd = new SqlCommand("SELECT [orderid],[processid],[orgid],[processdesc] ,[perwet] FROM [anghan].[dbo].[ProcessOrder] where orderid='" + DropDownList1.SelectedItem.Value + "' and processid=1 ", con);
cmd.CommandType = CommandType.Text;
// cmd.Parameters.AddWithValue("@Id", value);
cmd.Connection = con;
//con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
TextBox2.Text = dr["perwet"].ToString();
// DropDownList1.Items(DropDownList1.SelectedIndex).Text = dr["service"].ToString();
}
dr.Close();
//process 2
SqlCommand cmd2 = new SqlCommand("SELECT [orderid],[processid],[orgid],[processdesc] ,[perwet] FROM [anghan].[dbo].[ProcessOrder] where orderid='" + DropDownList1.SelectedItem.Value + "' and processid=2 ", con);
cmd2.CommandType = CommandType.Text;
// cmd.Parameters.AddWithValue("@Id", value);
cmd2.Connection = con;
//con.Open();
SqlDataReader dr2 = cmd2.ExecuteReader();
while (dr2.Read())
{
TextBox3.Text = dr2["perwet"].ToString();
// DropDownList1.Items(DropDownList1.SelectedIndex).Text = dr["service"].ToString();
}
dr2.Close();