Get a String for a month in a drop down

  • Thread starter Thread starter M K
  • Start date Start date
M

M K

I want to do a Stored Procedure or query from an SQL database that fills a
drop down list. The text member will be the month, and the value member will
be the number of the month. I can get the number out of SQL, but how about
the month?
 
Hi MK,

Why do you need to do it in server?
You can easily construct your DataTable in code.
If you still insist on sp, then you should take a look at case statament and
do a branch for each month.
 
But I am using a Drop down list. That is the only control that I need to
have data in.
I can fill a dataTable and do conversions on Databind, but not with a drop
down, or at least, I don't know how yet.
 
Hi,

See the thread Binding a ComboBox in Windows Form to a Hierarchical DataSet
below this one.
 
Sorry, found this out first:
SELECT DISTINCT DATENAME(month, EventDate) AS Month, MONTH(EventDate) AS
mInt
FROM dbo.mEvents
GROUP BY EventDate
ORDER BY MONTH(EventDate)

Month is the Text member and mInt is the Value member.
 
True, but you will have troubles with localization (if you need to localize,
of course).
 
Back
Top