Hi!
I have a asp.net control combo box. I want to pouplate it with the name of the months.
I am wring the code in the code behind. I am using vb.net as the code behind.
My code is
'Month
dim i as integer
dim myvar as string
i = 1
Do While i <= 12
myvar = MonthName(i, True)
cboMonth.Items.Add(myvar)
i = i + 1
Loop
I get the populated month names in the combobox, because of the function month name.
But in the value I want 1,2,3 not Jan, Feb, Mar...How to achive this.
Had been it ASP I wud have written:
do while iLoop <= 12
myvar = MonthName(iLoop,true)
Response.Write "<option value=" & iLoop & " selected>" & myvar & "</option>"
iLoop = i Loop+1
loop
This wud have given me the dsired result.
How to do in VB.NET?With a bit of R&D got the solution:
i = 1
Do While i <= 12
myvar = MonthName(i, True)
cboToMonth.Items.Add(New ListItem(myvar, i))
i = i + 1
Loop
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment