我正在使用 asp 表单视图。我想根据条件绑定文本框值。
<td style="height: 12px;
border-right: silver 1px solid;
border-top: silver 1px solid;
border-left: silver 1px solid;
border-bottom: silver 1px solid;">
<asp:TextBox ID="txtHaulZoneCodeLEM"
runat="server"
CssClass="cagText"
Text='<%# Bind("HaulZoneCodeLEM") %>'>
</asp:TextBox>
</td>
我试过这个:
<asp:TextBox
ID="txtHaulZoneCodeLEM"
runat="server"
CssClass="cagText"
Text='<%# ((TextBox) Container.DataItem).HaulZoneCodeLEM != 0 ? ((TextBox) Container.DataItem).HaulZoneCodeLEM : string.Empty %>'>
如何解决这个问题?
我搬到后面的代码:
<td style="height: 12px; border-right: silver 1px solid; border-top: silver 1px solid;
border-left: silver 1px solid; width: 339px; border-bottom: silver 1px solid;">
<asp:TextBox ID="txtHaulZoneCodeLEM" runat="server" CssClass="cagText" Text=ConvertHaulZoneCodeForDisplay('<%# Bind("HaulZoneCodeLEM") %>')>
</asp:TextBox>
</td>
在我的页面后面的代码中,我这样写:
Protected Function ConvertHaulZoneCodeForDisplay(ByVal str As String) As String
If str = 0 Then Return ""
End Function
End Class
我仍然在aspx页面中遇到错误..