0
我想要做的就是將一個ID分配給一個表格行,其值爲相關列的ID。ASP.NET VB Listview爲表格行分配ID
澄清。我有一個領域[ID]
[Name]
[Description]
一個數據表,並填充ListView
這樣的:(我在這裏簡化了代碼的清晰度)
<asp:ListView ID="MainList" runat="server" DataKeyNames="id">
<layouttemplate>
<dl id="header">
<dd class="rowHeader">Name</dd>
<dd class="rowHeader">Description</dd>
</dl>
<asp:Panel runat="server" ID="itemPlaceholder">
</asp:Panel>
</layouttemplate>
<itemtemplate>
<dl class="row">
<dd><%# Eval("name")%></dd>
<dd><%# Eval("description")%></dd>
</dl>
</itemtemplate>
</asp:ListView>
現在,我想是添加像這樣。
<dl class="row" id='<%# Eval("id")%>'>
當然,它的工作,但我需要通過它作爲一個變量,因爲我需要檢查與它的東西。像這樣:
<% Dim id as Integer = Eval("id") %>
<dl class="row" id='<%=id %>'>
我得到這個錯誤:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
而且我知道了爲什麼...爲什麼我需要這個是這樣我可以比較ID與會話變量,改變行類因此。
任何方式來解決這個問題?
會嘗試。謝謝。 – rexdefuror 2012-08-07 15:54:58
同樣的錯誤...我不得不使用不同的語法,因爲在這裏你使用C#內聯如果,這是VB標記:) – rexdefuror 2012-08-07 16:10:40
工作。謝謝:)我犯了一個錯誤設置它:D '
' 這是vb的確切代碼。 – rexdefuror 2012-08-07 16:20:29