HTML
<EditItemTemplate>
<td>
<asp:Label ID="LabelID" runat="server" Text='<%# Eval("sysID")%>'></asp:Label>
</td>
<td>
<asp:Label ID="Labelpar" runat="server" Text='<%# Eval("parameters")%>'></asp:Label>
</td>
<td>
<asp:TextBox ID="LabelValue" runat="server" Text='<%# Eval("value")%>'></asp:TextBox>
</td>
<td>
<asp:Button ID="btnEdit" runat="server" Text='Update' CommandName="Update" />
<asp:Button ID="Button1" runat="server" Text='Cancel' CommandName="Cancel" />
</td>
</EditItemTemplate>
VB
Protected Sub OnItemUpdating(sender As Object, e As ListViewUpdateEventArgs)
Dim svalue As TextBox = DirectCast(e.NewValues("value"), TextBox)
Dim sParameters As String = DirectCast(e.NewValues("parameters"), Label).Text
For Each row As DataRow In sysDT.Rows
If row("parameters").ToString() = sParameters Then
row("value") = svalue
Exit For
End If
Next
lvConfiguration.EditIndex = -1
BindListView()
End Sub
如果我断点到sub,则svalue什么都不是
错误
类型&#39; System.NullReferenceException&#39;的例外情况发生在 SiteMonitor-V1.dll但未在用户代码中处理
答案 0 :(得分:0)
首先,我使用了标签ID,后端代码中的变化很小
Dim svalue As String = TryCast(lvConfiguration.Items(e.ItemIndex).FindControl("LabelValue"), TextBox).Text
Dim sParameters As String = TryCast(lvConfiguration.Items(e.ItemIndex).FindControl("Labelpar"), Label).Text
这很好用