在不使用单独查询的情况下显示数据库中的dropdownlist值 [英] display dropdownlist values from database without using seperate query

查看:63
本文介绍了在不使用单独查询的情况下显示数据库中的dropdownlist值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有3个数据库表


这是显示表的下拉列表值



----------------
ID值
---------------
1赛尔
2 krish
3阿拉
4 Prabhu

接下来我要像桌子一样

技能
----------------------
1神
2个朋友
3家庭
4位亲戚

这是数据库中的文本框显示




现在,从上面的下拉数据库表和文本中,我应该使用My sql的linq实体框架在第三个表中输出.


ID PersonID SkillID
-------------------------
1 1 1
2 1 2
3 2 3
4 4 4

这是一个主键过程,在这三个ID的上方不应有任何重复的值

在我的输出中,我应该获得所有dropdownlist值,而无需使用单独的查询.


请寄给我任何相关的样品或例子


谢谢,



i have 3 database tables


this is a dropdown list values displaying table


person
----------------
ID VALUE
---------------
1 sai
2 krish
3 Allah
4 Prabhu

next i am having table like

skills
----------------------
1 God
2 Friend
3 Family
4 relative

this is textbox display from database




Now from the above dropdown database table and text i should get output in the third table by using linq entityframework of My sql.


Id PersonID SkillID
-------------------------
1 1 1
2 1 2
3 2 3
4 4 4

This is a primary key process there should not be any duplicate values from above these three ID''s

in my output i should get all dropdownlist values without using seperate query for it.


please send me any related samples or examples


Thanks,

推荐答案

您好,您可以使用
hi you can do this by using
ddl1.DataSource = some dataSource;
ddl1.DataTextField = "table column name";
ddl1.DataValueField = "table column name";
ddl1.DataBind();


DataTextField将是将在下拉列表中显示的文本,而DataValueField将是与文本相对应的值feild.两者都可能包含同一列,这取决于要检索和显示的信息.
如果要在下拉菜单中选择某些项目时恢复差异,则将不同的列绑定到下拉菜单

谢谢,我希望这会有所帮助.


DataTextField will be the text that will be displayed in dropdown and DataValueField will be the value feild that corresponds to text. both may contain same column as well it depends what information you want to retreive and display.
if you want to retreive differebt feild when some item is selected in dropdown then bind different columns to dropdown

thanks i hope that this may help.


这篇关于在不使用单独查询的情况下显示数据库中的dropdownlist值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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