2011年5月10日 星期二

使用LINQ 將 選取的listbox item轉成string 或string array

using System.Web.UI.WebControls;

string strArray[] = listboxTest.Items.Cast<ListItem>().Where(item => item.Selected).Select(p => p.Value).ToArray();

 string strTest = String.Join(",", listboxTest.Items.Cast<ListItem>().Where(item => item.Selected).Select(p => p.Value).ToArray());
         

沒有留言:

張貼留言

publish error allowDefinition='MachineToApplication'

一個老舊的aspx web form專案,調了一些功能建置成功,但進行部署時顯示以下錯誤。 在應用程式層級之外使用註冊為 allowDefinition='MachineToApplication' 的區段發生錯誤。錯誤的原因可能是虛擬目錄尚未在 IIS 中設定為...