我有一个链接按钮,我试图将参数传递到OnClick
事件处理程序。为此,我使用CommandArgument
字段。
我在listview中有此链接按钮,因此我使用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>
答案 0 :(得分:2)
它可能与引号有关 - 你到处都使用双引号,这可能会混淆解析器。尝试用单引号替换外部的:
CommandArgument='<%#Eval("TicketNum").ToString()%>'