Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27196

VS 2010 How to concatenate 2 columns (and format one) from my DataSet in a DropDownList ?

$
0
0
Good afternoon,

I have a dataset that countain 1 table with 2 columns "HOLIDAY_DATE" and "HOLIDAY_NAME" with about 25 rows....

I need to bind this dataset to a DropDownList and concatenate the "HOLIDAY_DATE" (DateTime Type) & " " & "HOLIDAY_NAME" (String)

I tried the following code below which kinda works... BUT... IT GIVES ME 01/01/2014 - 00:00:00 New Year


But what I am looking for is the date formatted as {0:MMMM d, yyyy} in order to get January 1st 2014 - New Years

Code:

dsHolidays.Tables(0).Columns.Add("DisplayText", GetType(string))
dsHolidays.Tables(0).Columns("DisplayText").Expression = "HOLIDAY_DATE + ' - ' + HOLIDAY_ID"

Me.ddlAddHoliday.DataSource = dsHolidays.Tables(0)
Me.ddlAddHoliday.DataTextField = "DisplayText"
Me.ddlAddHoliday.DataValueField = "HOLIDAY_DATE"
Me.ddlAddHoliday.DataBind()

So what I am looking to achieve is formatted "HOLIDAY_DATE" as {0:MMMM d, yyyy} & " " & "HOLIDAY_NAME" ----> January 1st 2014 - New Year

Any help would be much appreciated..

Thanks!

Viewing all articles
Browse latest Browse all 27196

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>