如何在下拉列表中的表上添加列 [英] how to add column on a table in dropdownlist

查看:72
本文介绍了如何在下拉列表中的表上添加列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何获取一个表的列以进入下拉列表,并将这些值用作参考
例如:-
如果我有一个emp表,并且我希望在dropdownlist中有一个空的详细信息,其中dropdownlist在其他页面中用作我的emp表的引用

how can i get the column of one table to get in the dropdownlist for the values are used as reference
Eg:-
if i have an emp table and i want the empid detail in the dropdownlist where the dropdownlist is used in other page as reference of my emp table

推荐答案

尝试一下

尝试一下

Try this

SqlCommand cmd=new SqlCommand()
cmd.commandtext="Select * from Emp";
//assign connection

DropdownList.DataSource=cmd.ExecuteReader();
DropdownList.DataValueField="Empid";
DropdownList.DataTextField="Empname";



您的下拉列表将显示员工姓名,并在数据库中存储员工ID



Your dropdown will display employees name and in database it''ll store employees id


这篇关于如何在下拉列表中的表上添加列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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