hudon77
Messages postés127Date d'inscriptionvendredi 21 janvier 2005StatutMembreDernière intervention29 mai 2014
-
7 mars 2005 à 01:44
kaskran
Messages postés35Date d'inscriptionmardi 30 septembre 2003StatutMembreDernière intervention 7 mars 2005
-
7 mars 2005 à 14:51
Salut! J'essai de trier un datagrid en cliquant sur le header des colonne mais j'ai lerreure suivante ...
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 68: Private Sub dg_SortCommand(ByVal source As Object, ByVal e As DataGridSortCommandEventArgs) Handles dg.SortCommand
Line 69: Dim dv As DataView = Session("dv")
Line 70: dv.Sort = e.SortExpression
Line 71: DataBind()
Line 72:
voici mon code
Dim cn
As
New Odbc.OdbcConnection("DRIVER={Microsoft Access Driver (*.mdb)};" & "DBQ=C:\Inetpub\wwwroot\annuaire\annuaire.mdb")
Dim ds
As
New DataSet
Private
Sub Page_Load(
ByVal sender
As System.Object,
ByVal e
As System.EventArgs)
Handles
MyBase.Load
'Put user code to initialize the page here
Dim da
As
New Odbc.OdbcDataAdapter("select * from personnes", cn)
da.Fill(ds)
dg.DataSource = ds
dg.DataBind()
End
Sub
Private
Sub cmdRecherche_Click(
ByVal sender
As System.Object,
ByVal e
As System.EventArgs)
Handles cmdRecherche.Click
Dim dt
As DataTable = ds.Tables(0)
Dim dv
As
New DataView(dt)
If RdoNom.Checked
Then
dv.RowFilter =
String.Format("nom like '{0}%'", txtRecherche.Text)
Else : dv.RowFilter =
String.Format("prenom like '{0}%'", txtRecherche.Text)
End
If
Session("dv") = dv
dg.DataSource = Session("dv")
dg.DataBind()
End
Sub
Private
Sub dg_PageIndexChanged(
ByVal source
As
Object,
ByVal e
As DataGridPageChangedEventArgs)
Handles dg.PageIndexChanged
dg.CurrentPageIndex = e.NewPageIndex
DataBind()
End
Sub
Private
Sub dg_SortCommand(
ByVal source
As
Object,
ByVal e
As DataGridSortCommandEventArgs)
Handles dg.SortCommand