0
我有一個鏈接按鈕,我試圖將參數傳入OnClick
事件處理程序。爲此,我正在使用CommandArgument
字段。在列表視圖中通過命令參數傳遞Eval
我有一個ListView,所以我retireving使用Eval
數據中此鏈接按鈕,所以我想是值傳遞到CommandArgument
這樣:
<asp:LinkButton id="BTN_ApproveTicket" runat="server" CommandArgument="<%#Eval("TicketNum").ToString()%>" OnClick="BTN_ApproveTicket_Click">
</asp:LinkButton>
我做這個確切的認爲一些表元素在我的頁面中,但是這個不起作用。
我得到的錯誤是它採用<%#Eval("TicketNum").ToString()
作爲文字,所以我得到一個服務器標籤沒有很好的格式化錯誤。任何想法如何解決這個將不勝感激。
這是AlternatingItemTemplate
是有問題:
<AlternatingItemTemplate>
<td style="<%#setTicketClass(Eval("TicketNum").ToString(), Eval("UnitID").ToString(), Eval("TicketDate").ToString())%>" >
<asp:LinkButton id="BTN_ApproveTicket" runat="server" CommandArgument='<%#Eval("TicketNum").ToString()%>' OnClick="BTN_ApproveTicket_Click">
<i class="fa fa-check-square-o" style="<%#setCheckBoxClass(Eval("Approved").ToString())%>" ></i>
</asp:LinkButton>
<br />
<br />
JobID:
<asp:Label ID="JobIDLabel" runat="server" Text='<%# Eval("JobID") %>' />
<br />
Ticket #:
<asp:Label ID="TicketNumLabel" runat="server" Text='<%# Eval("TicketNum") %>' />
<br />
Unit:
<asp:Label ID="UnitIDLabel" runat="server" Text='<%# Eval("UnitID") %>' />
<br />
Total Ticket Hours:
<asp:Label ID="TicketHoursLabel" runat="server" Text='<%# Eval("TicketHours") %>' />
<br />
Total Product:
<asp:Label ID="TicketProductLabel" runat="server" Text='<%# Eval("TicketProduct") %>' />
<br />
Ticket Date:
<asp:Label ID="TicketDateLabel" runat="server" Text='<%# Eval("TicketDate", "{0:MMM dd yyyy}") %>' />
<br />
Charge To Customer:
<asp:Label ID="ChargeToCustomerLabel" runat="server" Text='<%# Eval("ChargeToCustomer") %>' />
<br />
Received From Customer:
<asp:Label ID="RecievedToCuLabel" runat="server" Text='<%# Eval("RecievedToCu") %>' />
<br />
Deliver To Customer:
<asp:Label ID="DeliverTocu" runat="server" Text='<%# Eval("DeliverToCu") %>' />
<br />
Charged To LSD:
<asp:Label ID="LBL_ChargedToLSD" runat="server" Text='<%# Eval("ChargedToLSD") %>' />
<br />
Received From LSD:
<asp:Label ID="RecievedFromLSDLabel" runat="server" Text='<%# Eval("RecievedFromLSD") %>' />
<br />
Delivered To LSD:
<asp:Label ID="DeliveredToLSDLabel" runat="server" Text='<%# Eval("DeliveredToLSD") %>' />
<br />
Subtotal:
<asp:Label ID="SubtotalLabel" runat="server" Text='<%# Eval("Subtotal", "{0:C}") %>' Font-Bold="True" />
<br />
GST:
<asp:Label ID="GSTLabel" runat="server" Text='<%# Eval("GST", "{0:P}") %>' Font-Bold="True" />
<br />
Total:
<asp:Label ID="TotalLabel" runat="server" Text='<%# Eval("Total", "{0:C}") %>' Font-Bold="True" />
<br />
Job Notes:
<asp:Label ID="PreJobNotesLabel" runat="server" Text='<%# Eval("PreJobNotes") %>' />
<br />
Job Description:
<asp:Label ID="JobDescLabel" runat="server" Text='<%# Eval("JobDesc") %>' />
<br />
Time Created:
<asp:Label ID="TimeCreatedLabel" runat="server" Text='<%# Eval("TimeCreated", "{0: MMM-dd-yyyy HH:mm}") %>' />
<br />
Created By:
<asp:Label ID="CreatedByLabel" runat="server" Text='<%# Eval("CreatedBy") %>' />
<br />
<asp:LinkButton class="btn-inverse" id="EditButton" runat="server" CommandName="Edit" Text="Edit" Enabled='<%# checkButtonEnabled() %>' style="padding: 2px 8px; text-decoration: none; border: solid 1px;" >
<span class="glyphicon glyphicon-edit"></span> Edit
</asp:LinkButton>
<asp:LinkButton class="btn-inverse" id="DeleteButton" runat="server" CommandName="Delete" Text="Delete" onclientclick="return DeleteItem()" Enabled='<%# checkButtonEnabled() %>' style="padding: 2px 8px; text-decoration: none; border: solid 1px;" >
<span class="glyphicon glyphicon-trash"></span> Delete
</asp:LinkButton>
<asp:LinkButton class="btn-inverse" id="SelectButton" runat="server" CommandName="Select" Text="Show Product" style="padding: 2px 8px; text-decoration: none; border: solid 1px; white-space: nowrap;" >
<span class="glyphicon glyphicon-menu-down"></span> Show Product
</asp:LinkButton>
</td>
</AlternatingItemTemplate>
我給了這個嘗試,但仍然沒有運氣。同樣在倒車和使用單一的內部。 – 2015-03-31 16:02:37
真奇怪。你可以發佈整個列表項目模板嗎? – Andrei 2015-03-31 16:05:20
我會更新這個問題。 – 2015-03-31 16:05:56