2016-02-19 76 views
0

我很難在asp腳本中格式化整數ASP.NET中的格式整數

現在整數的格式是######。我想將其格式化爲#### - ##。例如:格式201602至2016-02。誰可以幫我這個事?非常感謝!

<asp:DropDownList ID="From" runat="server" DataSourceID="ShipDate"DataTextField="intYearMonth"> <asp:ListItem Text="" Value="0"/> </asp:DropDownList> 
+1

任何你可以將它實際存儲爲2的方式單獨的值或作爲'DateTime'?你的方式似乎有風險。 –

回答

0

你可以一切加載與For Each後完成這個...

注意 - 沒有錯誤檢查在這裏,你可能要搞定...

For Each item As ListItem In DropDownList1.Items 
    item.Text = item.Insert(4, "-") 
Next 

輸出 - 2016-02