Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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
Posted

1 solution

Hi,
If you provide the Date part before binding, I mean in your Query, then binding code is very simple:
ASP.NET
<asp:dropdownlist datasource="DataSourceName" datavaluefield="id" datatextfield="d"  ...  />
<asp:sqldatasource 
          id="DataSourceName"
          runat="server"
          ConnectionString="<%$ ConnectionStrings:ConNameInConfig%>"
          SelectCommand="SELECT id,year(date) as d FROM tblName"
      </asp:sqldatasource>


I hope it helps.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900