如何根据选择的组合框从数据库填充文本框值。 [英] How to populate Text box value from database as per selection of combo box.

查看:83
本文介绍了如何根据选择的组合框从数据库填充文本框值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的物品主要跟随栏中存在。



否,类型,描述,部件号



如果用户选择零件号(组合框),则在我的发票表单上,类型和说明(文本框)应根据零件号(组合框)值的选择进行填充。





任何人都可以给我建议



提前致谢。

In my Item Master following column are exists.

No, Type , Desc , Part No.

On My Invoice form if user select Part no (combo box) , Type & Desc (Text box) should get fill as per selection of Part no (combo box) value.


Can any one give me suggestion

Thanks in advance.

推荐答案

在你的组合框上添加onselectedindexchanged事件。

然后在代码后面,即在.vb文件中







string partno = yourcomboboxname.SelectedItem.Value;



然后使用此partno从db获取整行。



然后将这些值添加到您需要的文本框中。



如果partno将是unquie然后你得到单数据库中的一行。





例如



SqlDataReader reader = cmd。 ExecuteReader(从表名中选择partno =+ partno;



while(reader.Read)

{

TextBox1.Text =读者[CoulmnName];

}



在vb中使用相同的代码没有;:)



希望这能解决你的问题......
Add event onselectedindexchanged on your combobox.
then in code behind i.e in .vb file

write

string partno = yourcomboboxname.SelectedItem.Value;

then use this partno to fetch whole row from db.

then add those value to your required text box.

if partno will be unquie then you get single row from database.


e.g.

SqlDataReader reader = cmd.ExecuteReader("Select from tablename where partno = " +partno;

while(reader.Read)
{
TextBox1.Text = reader["CoulmnName"];
}

Use same code in vb WITHOUT ";" :)

Hope this will solve your problem.....


这篇关于如何根据选择的组合框从数据库填充文本框值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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