0
我正在一個asp.net頁面上工作,我需要將一個可選參數添加到超鏈接的href。參數值在代碼隱藏中。快捷方式服務器端代碼塊
這裏是超鏈接:
<a href='FileView.aspx?fid=<%#Eval("FileOrFolderID") %>&uid=<%=UserID %> <%=(ProfileType.HasValue && ProfileId.HasValue?"&profiletype=" + (int)ProfileType.Value + "&profileid=" + ProfileId.Value:"") %>'
<%#Convert.ToBoolean(Eval("IsFolder")) ? "style='display:none;'" : "style='display:block;'" %>
id="aDownLoad">
<%# Eval("Name").ToString().HE()%></a>
我想補充一點:
<%=(Convert.ToBoolean(Eval("IsFolder")) ? "" : "&id=" + CurrentID) %>
,使它看起來像這樣:
<a href='FileView.aspx?fid=<%#Eval("FileOrFolderID") %>&uid=<%=UserID %> <%=(Convert.ToBoolean(Eval("IsFolder")) ? "" : "&id=" + CurrentID) %> <%=(ProfileType.HasValue && ProfileId.HasValue?"&profiletype=" + (int)ProfileType.Value + "&profileid=" + ProfileId.Value:"") %>'
<%#Convert.ToBoolean(Eval("IsFolder")) ? "style='display:none;'" : "style='display:block;'" %>
id="aDownLoad">
<%# Eval("Name").ToString().HE()%></a>
不過是給出了這樣的錯誤:
An exception of type 'System.InvalidOperationException' occurred in System.Web.dll but was not handled in user code
Additional information: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
請建議此問題的解決方案