将Sql查询的输出绑定到下拉列表 [英] Binding out put of Sql query to the drop downlist

查看:89
本文介绍了将Sql查询的输出绑定到下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我想将选择查询的输出绑定到dropdownlist
例如,我只需要日期部分的年份部分
从表中选择年份(日期)".我需要将唯一的年份部分绑定到下拉列表

我该怎么做

谢谢Inadvance

hi all,
i want to bind the output of the select query to the dropdownlist
example i need only the year part fron the date column
"select year(date) from table" .i need the only year part to be binded to the Dropdown

how can i do this

Thanks Inadvance

推荐答案


如果您在绑定之前提供Date部分,那么我的意思是在您的查询中,那么绑定代码非常简单:
Hi,
If you provide the Date part before binding, I mean in your Query, then binding code is very simple:
<asp:dropdownlist datasource="DataSourceName" datavaluefield="id" datatextfield="d"  ...  />
<asp:sqldatasource 

          id="DataSourceName"

          runat="server"

          ConnectionString="<%


ConnectionStrings:ConNameInConfig%>" span> =" 选择id,year(date)为d FROM tblName" < /asp:sqldatasource >
ConnectionStrings:ConNameInConfig%>" SelectCommand="SELECT id,year(date) as d FROM tblName" </asp:sqldatasource>



希望对您有所帮助.



I hope it helps.


这篇关于将Sql查询的输出绑定到下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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