关于文本框中的文本罐事件
本文关键字:文本 事件 于文本 | 更新日期: 2023-09-27 18:30:15
我正在创建一个网站,该网站有一个ID为txt5的文本框,用于存储Customer_reference。我想要的只是在我通过获取值键入值时自动填充其他具有客户详细信息customer_reference文本框。为此,我正在使用文本更改事件
protected void txt5_TextChanged1(object sender, EventArgs e)
{
try
{
SqlConnection con = new SqlConnection();
con.ConnectionString = (Class1.con_string);
con.Open();
string query = string.Format("select cust_name from customer_master where cust_slno='{0}'",txt4 .Text .ToString ());
SqlCommand cmd=new SqlCommand(query,con);
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
string type = reader.GetValue(0).ToString();
txt6.Text = type;
Page.ClientScript.RegisterStartupScript(GetType(), "UserDialogScript", "alert('"User successfully updated'");", true);
}
catch (Exception ex)
{
Page.ClientScript.RegisterStartupScript(GetType(), "UserDialogScript", "alert(ex);", true);
}
}
但是txt6的值没有更新 请帮助编码中的问题。
为什么要在文本框上调用事件 ondatabinding?看看删除它是否可以解决您的问题。