Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
595
databind error after user has clicked a header to sort grid
posted

(1) Bind Button: I use this code to perform a grid bind.

‘ (1) Code in Search button to bind data to grid.
da = New SqlDataAdapter(sSQL, con) ‘

da.Fill(ds, "TiffIndex")

Dim dv As DataView = ds.Tables("TiffIndex").DefaultView

 

panelInvoiceList.Visible = True

' bind grid to dataview.

Me.UltraWebGrid1.Clear()

Me.UltraWebGrid1.DataSource = dv

Me.UltraWebGrid1.DataBind()

(2) User clicks the Invoice_No field header to sort grid.

(3) User clicks the Bind button and the code fails on the line:

Me.UltraWebGrid1.DataBind()

Question: Do I need to remove the original sort that the user chose?

Error message:

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 181:
Line 182:        Me.UltraWebGrid1.DataSource = dv
Line 183:        Me.UltraWebGrid1.DataBind()
Line 184:
Line 185:        ' count records retrieved and display on form.


Source File: C:\Inetpub\wwwroot\satellitelite_aga_appo\ManageSystem.aspx.vb    Line: 183

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   Infragistics.WebUI.UltraWebGrid.UltraGridColumn.get_SortingAlgorithmResolved() +54
   Infragistics.WebUI.UltraWebGrid.RowsCollection.Sort(Boolean caseSensitive) +1246
   Infragistics.WebUI.UltraWebGrid.UltraWebGrid.SortGroupRows(RowsCollection rows) +236
   Infragistics.WebUI.UltraWebGrid.UltraWebGrid.PerformGroupRows() +324
   Infragistics.WebUI.UltraWebGrid.DBBinding.BindList(IEnumerable datasource) +3663
   Infragistics.WebUI.UltraWebGrid.DBBinding.DataBind(Object dataSource, String dataMember) +1673
   Infragistics.WebUI.UltraWebGrid.UltraWebGrid.DataBind() +1621
   satellitelite_aga_appo.ManageSystem.DisplayGridData(String sSQL) in C:\Inetpub\wwwroot\satellitelite_aga_appo\ManageSystem.aspx.vb:183
   satellitelite_aga_appo.ManageSystem.btnSearch_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\satellitelite_aga_appo\ManageSystem.aspx.vb:214
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565