您好如何将数据绑定到sql的下拉列表中? [英] hi how to bind data to a drop down list from sql?

查看:71
本文介绍了您好如何将数据绑定到sql的下拉列表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi如何将数据从sql绑定到aspx页面中的下拉列表?

hi how to binddata to a dropdown list in aspx page from sql?

推荐答案

http://www.dotnetfunda.com/forums/thread4161-how-to-bind-database-table-to-dropdownlist- value.aspx [ ^ ]


首先使用dataadapter
填充数据集
First fill the dataset using dataadapter
dropdown.DataTextField="column to display";
dropdown.DataValueField="column to insert to DB";


试试这个
connection.Open();
SqlCommand cmd="Select * from table";
cmd.Connection=connection;
dropdown.DataSource=cmd.ExecuteReader();
dropdown.DataTextField="column to display";
dropdown.DataValueField="column to insert to DB";
dropdown.DataBind();


这篇关于您好如何将数据绑定到sql的下拉列表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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