绑定到 属性 时带撇号的字符串会加倍
String with apostrophe doubles when bound to property
我有一个带有单元格的 radgridview,其数据可能包含撇号。选择行后,行上下文将转换为 public 属性的集合。除了带撇号的单元格外,这很好用。
Private Sub dgSelectOrder_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs)
Dim row = TryCast(sender, GridViewRow)
Dim selectedOrder = TryCast(row.DataContext, myProperties)
如果单元格数据有撇号,例如 LET'S GO,则 属性 returns 值 LET''S GO. The apostrophe is doubled. If that data gets saved back to the database, then retrieved again, the property returns LET''''S GO。
如何正确投射行数据?
Public Class myProperties
Public Property pProjectNbr As String = String.Empty
谢谢。
我不应该这样做,但这是唯一可行的方法。我有类似的代码将 row.datacontext 投射到别处。该代码使用撇号按预期运行。
Private Sub dgArchivedOrders_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs)
Dim row = TryCast(sender, GridViewRow)
Dim selectedOrder = TryCast(row.DataContext, myProperties)
If selectedOrder.pProjectNbr.Contains("''") Then
Dim convertThis As String = selectedOrder.pProjectNbr
selectedOrder.pProjectNbr = convertThis.Replace("''", "'")
End If
我有一个带有单元格的 radgridview,其数据可能包含撇号。选择行后,行上下文将转换为 public 属性的集合。除了带撇号的单元格外,这很好用。
Private Sub dgSelectOrder_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs)
Dim row = TryCast(sender, GridViewRow)
Dim selectedOrder = TryCast(row.DataContext, myProperties)
如果单元格数据有撇号,例如 LET'S GO,则 属性 returns 值 LET''S GO. The apostrophe is doubled. If that data gets saved back to the database, then retrieved again, the property returns LET''''S GO。
如何正确投射行数据?
Public Class myProperties
Public Property pProjectNbr As String = String.Empty
谢谢。
我不应该这样做,但这是唯一可行的方法。我有类似的代码将 row.datacontext 投射到别处。该代码使用撇号按预期运行。
Private Sub dgArchivedOrders_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs)
Dim row = TryCast(sender, GridViewRow)
Dim selectedOrder = TryCast(row.DataContext, myProperties)
If selectedOrder.pProjectNbr.Contains("''") Then
Dim convertThis As String = selectedOrder.pProjectNbr
selectedOrder.pProjectNbr = convertThis.Replace("''", "'")
End If