Datagrid order by

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a datagrid with values and when I order by one column and select one row the row selected not is de correct is that the original one row before order

The code is that
Dim gTable As New DataTable("Response"

Dim t As New DataGridTableStyle(False
Dim c As DataGridColumnStyl

gTable = New DataTable("Response"

gTable.Columns.Add("PatientID", System.Type.GetType("System.String")
gTable.Columns.Add("PatientName", System.Type.GetType("System.String")

t.MappingName = "Response

c = New DataGridTextBoxColum
c.MappingName = "PatientID
c.HeaderText = "PatientID
c.Width = 4
t.GridColumnStyles.Add(c

c = New DataGridTextBoxColum
c.MappingName = "PatientName
c.HeaderText = "PaientName
c.Width = 25
t.GridColumnStyles.Add(c

t.GridColumnStyles.Add(c
grdResponse.TableStyles.Clear(
grdResponse.TableStyles.Add(t
grdResponse.DataSource = gTabl


For i = ifirst To gWL.FirstChild.ChildNodes.Count -
lMatch = gWL.FirstChild.ChildNodes(i
lRow = gTable.NewRow(
lRow("PatientID") = GetValue("0010", "0020", lMatch
lRow("PatientName") = GetValue("0010", "0010", lMatch
Nex

' Sort datagrid column PatientNam
Dim lDataView As DataVie
lDataView = gTable.DefaultVie
lDataView.Sort = "PatientName ASC

And when I select one row
If grdResponse.CurrentRowIndex >= 0 The
msgbox(grdResponse.DataSource.rows(grdResponse.CurrentRowIndex).Item(0)

view PatientID incorrect is the patientID before order by a columns patientname ascendent

Anybody can i help me?

Thanks
 
Hi Silvia,

I am not sure because I never use the default view, I make the dataview the
datasource, you can try this.

replace the sensentence
grdResponse.DataSource = gTable
for after the creation of the dataview
grdResponse.DataSource = lDataview

I hope this helps?

Cor

I have a datagrid with values and when I order by one column and select
one row the row selected not is de correct is that the original one row
before order.
 
Back
Top