按Tab键后,在文本框中填充数据库中的数据 [英] populate data from database in a textbox after press tab key
问题描述
亲爱的所有人,
我想在按Tab键后在文本框中填充数据库中的数据.
事情就是这样...
我有3个文本框.在文本框1中,我将插入2;在文本框2中,我将插入2.按下Tab键后,文本框3.
如果有人知道,请分享知识.
谢谢avi ....
Dear All,
i want to populate data from database in a text box after press tab key.
the thing is like that....
where i am having 3 textboxes.In textbox 1 i am inserting 2, and In textbox 2 i am inserting 2. And I want do addition.Now i have a procedure where i am doing addition.and i want to fetch addition value into the textbox 3 after pressing tabkey.
if someone know please share the knowledge.
thanks avi....
推荐答案
在aspx页面中写
In the aspx page write
<asp:textbox id="TextBox1" runat="server" autopostback="true" ontextchanged="TextBox1_TextChanged" xmlns:asp="#unknown" />
<asp:textbox id="TextBox2" runat="server" autopostback="true" ontextchanged="TextBox1_TextChanged" xmlns:asp="#unknown" />
<asp:textbox id="TextBox3" runat="server" xmlns:asp="#unknown" />
在页面后面的代码中
In Code behind page
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
if(TextBox1.Text.Length != 0 && TextBox2.Text.Length != 0)
{
TextBox3.Text = (Convert.ToInt32(TextBox1.Text) + Convert.ToInt32(TextBox2.Text)).ToString();
}
}
试试上面的代码
我添加了一个事件名称OnTextChanged,它将在您更改文本框的文本时触发.
Try above code
I have added a event name OnTextChanged which will fire when u change the text of the textbox.
这篇关于按Tab键后,在文本框中填充数据库中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!