Ordinamento dataview

mercoledì 11 giugno 2008 - 18.03

ruby18 Profilo | Newbie

E' possibile ordinare il dataview per piu di una colonna????

Dainesi Profilo | Senior Member

Certo che è possibile, basta che separi con una virgola i campi ordinati.
Ti incollo un esempio che trovi nella rete:

Private Sub SortByTwoColumns() ' Get the DefaultViewManager of a DataTable. Dim view As DataView = DataTable1.DefaultView ' By default, the first column sorted ascending. view.Sort = "State, ZipCode DESC" End Sub

ruby18 Profilo | Newbie

a me da il seguente errore
Informazioni aggiuntive: Index -1 is not non-negative and below total rows count.
come mai?

Dainesi Profilo | Senior Member

Facciamo prima se posti il codice completo

ruby18 Profilo | Newbie

questo è il codice, il problema è che nel database idAutista è la chiave primaria

Private Sub sel_Autista_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sel_Autista.SelectedIndexChanged
If Not bSave And Not sel_Autista.SelectedValue Is Nothing Then
Dim row As dsSubVettori.AutistaRow
row = dvAutista.Item(dvAutista.Find(sel_Autista.SelectedValue)).Row()
ins_CognomeNome.Text = row.CognomeNome
ins_ScadenzaPatente.Checked = Not row.IsScadenzaPatenteNull
If Not row.IsScadenzaPatenteNull Then ins_ScadenzaPatente.Value = row.ScadenzaPatente
ins_ScadenzaPatenteADR.Checked = Not row.IsScadenzaPatenteADRNull
If Not row.IsScadenzaPatenteADRNull Then ins_ScadenzaPatenteADR.Value = row.ScadenzaPatenteADR
dvAutista.Sort = "idAutista, CognomeNome DESC"
End If
End Sub

ruby18 Profilo | Newbie

Private Sub sel_Autista_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sel_Autista.SelectedIndexChanged
If Not bSave And Not sel_Autista.SelectedValue Is Nothing Then
Dim row As dsSubVettori.AutistaRow
row = dvAutista.Item(dvAutista.Find(sel_Autista.SelectedValue)).Row()
dvAutista.Sort = "CognomeNome"
ins_CognomeNome.Text = row.CognomeNome
ins_ScadenzaPatente.Checked = Not row.IsScadenzaPatenteNull
If Not row.IsScadenzaPatenteNull Then ins_ScadenzaPatente.Value = row.ScadenzaPatente
ins_ScadenzaPatenteADR.Checked = Not row.IsScadenzaPatenteADRNull
If Not row.IsScadenzaPatenteADRNull Then ins_ScadenzaPatenteADR.Value = row.ScadenzaPatenteADR
End If
End Sub
aggiungendo il sort mi da come errore index -1 is not non-negative and below total rows count,
come mai? cosa posso fare?
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5