从数据表中自动获取数据 [英] fetch data automatically from the datatable

查看:109
本文介绍了从数据表中自动获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的webform中有20个文本框,并且我的插入更新删除按钮正在工作。

数据保存到数据表中。我正在使用三层架构。

现在我想要当我在txtid文本框控件中输入id时,所以从datarow相关的其余字段应该自动进入所有文本框...

i have 20 textboxes in my webform and and my insert update delete buttons are working.
data is saving into the datatable. i am using three tier architecture.
now i want when i enter id inside txtid textbox control so rest of fields which is related from the datarow should be automatically come inside the all textboxes...

推荐答案

通过autopostback你可以实现这个..它完全非常简单。

文本框你想把id ..

添加autopostback =true

然后在设计视图中,单击它后面的代码文本框..

这个

Public void txtboxid_selectedchanged(发件人arg)

{

写收集以收集与ID FROM DATAREADER相关的数据..



收集数据的程序类型

并将价值分配给其他文本框..

LIKE ..

txtname.Text = DataReader的的[0]。价值。

Txtphone.Tex t = datareader的[1]值

}

使用这个概念肯定会对你有帮助。

U可以从datareader或数据集中获取值。如你所愿。

了解如何在获取值后分配值..



完成后完成此操作..输入您需要从数据库派生的id或数据,并在文本框外单击一下..如果您需要没有任何单击,请在后面的代码上使用延迟代码: - )
By means of autopostback u can achieve this.. its totally very simple.
The textbox u want to put the id..
Add autopostback="true"
Then on design view , click the textbox it take u to code behind..
On this
Public void txtboxid_selectedchanged(sender arg)
{
WRITE THE QUERY to COLLECT the datum related to the id FROM DATAREADER..
Or
Type of the procedure to collect the datas
AND ASSIGN THE VALUES TO THE OTHER TEXTBOX..
LIKE..
txtname.Text=datareader's[0].value.
Txtphone.Tex t=datareader's[1]value
}
Use this concept it will definitely help's u.
U can get the value from datareader or dataset. As ur wish.
Go through that how to assign the value after getting the values..

After done althose this done.. enter the id or data u need to derive from the database ,and one click on outside the textbox.. if u need without any click go with delay code on code behind:-)


这篇关于从数据表中自动获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆