从Datagrid.SelectedItems读取数据时出错

时间:2013-06-10 10:59:14

标签: vb.net silverlight xaml

Light Silver Project从Datagrid1.SelectedItems读取的数据量没有问题,但是当我在服务器上运行应用程序时,它会出现以下错误:

  

尝试方法'Microsoft.VisualBasic.CompilerServices.Symbols + Container.InvokeMethod(Method,System.Object [],Boolean [],System.Reflection.BindingFlags)'来访问方法'VB $ AnonymousType_9 6<System.__Canon,System.__Canon,System.Nullable 1,System.Nullable`1,System.Int32,System .__ Canon&gt; .get_Contacts_Name()'失败。

我的代码是:

标题

Private Sub LoadDataGridItems(sender As Object, e As EventArgs)
    Try
        Dim linq = (From n In ds.tbl_PHContacts Where n.Contacts_Name.ToString.Trim.Contains(txtContactName.Text) And n.Contacts_Location.ToString.Trim.Contains(txtLocation.Text) And n.Contacts_OfficeID.Equals(My_Class.CurrentUserOfficeId) Select New With { _
                    .Contacts_Name = n.Contacts_Name, _
                    .Contacts_Location = n.Contacts_Location, _
                    .Contacts_IsPrivate = n.Contacts_IsPrivate, _
                    .Contacts_IsPersonalize = n.Contacts_IsPersonalize, _
                    .Contacts_ID = n.Contacts_ID, _
                    .Contacts_Image = n.Contacts_Image
                    })
        DataGrid1.DataContext = ds.tbl_PHContacts
        DataGrid1.ItemsSource = linq
    Catch ex As Exception
        MessageBox.Show(ex.Message, "phSearch.LoadDataGridItems", MessageBoxButton.OK)
    End Try
End Sub



  Private Sub DataGridimgEdit_Click(sender As System.Object, e As System.Windows.Input.MouseButtonEventArgs)
      Try
          Dim frm As New phRegister
          frm.Tag = DataGrid1.SelectedItems(0).[Contacts_ID].ToString
          frm.Show()
      Catch ex As Exception
          MessageBox.Show(ex.Message, "phSearch.DataGridimgEdit_Click", MessageBoxButton.OK)
      End Try
  End Sub

0 个答案:

没有答案