1

我正在将数据集表值加载到 .xml 表中。如果有结果,我会通过电子邮件发送此表。如何将空列加载到下面的 .xml 表中?例如,_New_Invoice_Number 有时会为 Null,因为它是一个可为空的值。

 Dim void = _
            <html>
                <body>
                    <table border="1">
                        <tr><th>Store #</th><th>Invoice Date</th><th>Invoice #</th><th>Vehicle Tag</th><th>Void Reason</th><th>Invoice Total</th><th>New Invoice #</th><th>Vehicle Tag</th><th>New Invoice Total</th><th>Re-Tendered?</th><th>User Name</th></tr>
                        <%= From vtest In Me.DataDeliveryServiceDataSet.datatable.AsEnumerable _
                            Select <tr><td><%= vtest.Store_Number %></td>
                                       <td><%= Convert.ToDateTime(vtest.Invoice_Date).ToString("M/d/yy") %></td>
                                       <td><%= vtest.Invoice_Number %></td>
                                       <td><%= vtest.Vehicle_Tag %></td>
                                       <td><%= vtes.Void_Reason %></td>
                                       <td><%= vtest.Invoice_Total %></td>
                                       <td><%= vtest._New_Invoice__ %></td>
                                       <td><%= vtest._Vehicle_Tag %></td>
                                       <td><%= vtest.New_Invoice_Total %></td>
                                       <td><%= vtest._Re_tendered_ %></td>
                                       <td><%= vtest.User_Name %></td></tr> %>
                    </table>
                </body>
            </html>
4

1 回答 1

1

这是一个例子:

Sub Main()
    Dim a As Nullable(Of Integer)
    Dim b As String

    Dim c = IIf(IsNothing(a), "", a.ToString())
    Dim d = IIf(IsNothing(b), "", b)
End Sub

<td><%= IIf(IsNothing(vtest.Vehicle_Tag), "", vtest.Vehicle_Tag) %></td>
<td><%= IIf(IsNothing(vtest.Invoice_Number), "", vtest.Invoice_Number.ToString()) %></td>

另一种选择是在 SQL 端处理 Null:

select coalesce(Vehicle_Tag, '') from myTable
于 2012-08-13T17:50:51.460 回答