TextBox TextChange不起作用 [英] TextBox TextChange not working
本文介绍了TextBox TextChange不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个TextBox_TextChange取决于用户级别,它将执行为该用户设置的数学函数。我有一个If Else声明。当我在文本框中输入一个数字并点击标签或点击下一个文本框时,如果用户有学期级别或四分之一级别,它应该触发Textbox_Textchange并触发数学运算符。数学运算符或If Else语句不起作用。代码出了什么问题?
I havs a TextBox_TextChange depending on the user Level it will do the math function that is set up for that user. I have an If Else statement in place. When I enter a number into a textbox and hit tab or click ti the next textbox it should fire the Textbox_Textchange and fire the math operators if the user has semester level or a quarter level. The math operator or If Else statement is not working. What is wrong with the code?
protected void TextBoxNCC_TextChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
con.Open();
if (true)
{
SqlCommand level = new SqlCommand("Select INST_ID, Calendar from Table44 where INST_ID = @INST_ID", con);
level.Parameters.Add(new SqlParameter("INST_ID", TextBoxINST_ID.Text));
SqlDataReader reader = level.ExecuteReader();
DataTable dt1 = new DataTable();
dt1.Load(reader);
foreach (DataRow dr1 in dt1.Rows)
{
string returnedLevel = (dr1[0].ToString());
int inst_id = Convert.ToInt32(dr1[2].ToString());
Session["inst_id"] = inst_id;
if (returnedLevel == "Semester")
{
int i = Convert.ToInt32(TextBoxNCC.Text);
int j = 168;
TextBoxNCCDR.Text = Convert.ToString(i / j);
}
else if (returnedLevel == "Quarter")
{
int i = Convert.ToInt32(TextBoxNCC.Text);
int j = 120;
TextBoxNCCDR.Text = Convert.ToString(i / j);
}
}
}
}
}
<td class="style27">
<asp:TextBox ID="TextBoxNCC" runat="server" Width="180px"
ontextchanged="TextBoxNCC_TextChanged" AutoPostBack="True"></asp:TextBox>
</td>
推荐答案
drl [2]不存在,因为它基于0并且您只选择2列。您想要使用drl [0]。
drl[2] does not exist because it is 0 based and you are only selecting 2 columns. You want to use drl[0] instead.
这篇关于TextBox TextChange不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文