我已經在我的aspx頁面一個下面的代碼:如何在aspx頁面設置屬性的Guid
<% foreach (Dependency dep in this.Common.GetDependencies(this.Request.QueryString["Name"]))
{ %>
<ctl:DependencyEditor DependencyKey='<%= dep.Key %>' runat="server" />
<% } %>
當我運行它,我得到以下錯誤:
Parser Error Message: Cannot create an object of type 'System.Guid' from its string representation '<%= dep.Key %>' for the 'DependencyKey' property.
有什麼我可以創建一個控件並通過aspx頁面中的Guid?我真的很討厭必須循環,並在後面的代碼中創建這些控件,僅僅是因爲它......
注意:依賴項對象上的Key屬性是 guid。
是在DependencyKey屬性是一個GUID也是一個屬性。 – 2008-10-06 14:58:35
你使用MVC嗎?我認爲這是因爲你正在使用%=語法,它總是試圖超過一個字符串。如果您未使用MVC,請使用Repeater,它將允許您使用%#語法。這將在數據綁定上執行正確的類型轉換。 – 2008-10-06 15:26:16