Hi,
On my sample web form i am using webgrid and webcombo and webcombo is bind to one of the grid column. I am using updatecell event of an ASP.NET grid to update values to DB. I have upgraded my control's to Infragistics 9.1 for CLR 2.0 from 7.3. The code behind updatecell was working fine for 7.3 but after upgrade i am getting the following error message every time i call the event. I debug though all lines but i am not getting any error.
Error
Server Error in '/' Application.
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
[NullReferenceException: Object reference not set to an instance of an object.] Infragistics.WebUI.UltraWebGrid.UltraWebGrid.UpdateDBRow(UltraGridRow row, UltraGridRow oldRow) +236 Infragistics.WebUI.UltraWebGrid.UltraWebGrid.ProcessChanges(StateChanges stateChanges, Boolean fireEvents) +1560 Infragistics.WebUI.UltraWebGrid.UltraWebGrid.RaisePostDataChangedEvent() +161 System.Web.UI.Page.RaiseChangedEvents() +165 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1485
My code File
Public Partial Class TestCombo Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Try If Page.IsPostBack = False Then Dim dtcity As New DataTable dtcity.Columns.Add("CityId", GetType(Int16)) dtcity.Columns.Add("City", GetType(String))
dtcity.Rows.Add(New Object() {1, "Nuneaton"}) dtcity.Rows.Add(New Object() {2, "London"}) dtcity.Rows.Add(New Object() {3, "Coventry"})
WebCombo1.DataSource = dtcity WebCombo1.DataTextField = "City" WebCombo1.DataValueField = "CityId"
setGrid(1)
End If
WebCombo1.Columns(0).Hidden = True
Catch ex As System.Exception Response.Write(ex.Message) End Try End Sub
Private Sub setGrid(ByVal cityVal As Int16) Try Dim dt As New DataTable
dt.Columns.Add("Name", GetType(String)) dt.Columns.Add("City", GetType(Int16))
dt.Rows.Add(New Object() {"Test name", cityVal})
UltraWebGrid1.DataSource = dt UltraWebGrid1.DataBind()
Catch ex As System.Exception Throw ex End Try End Sub
Private Sub UltraWebGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles UltraWebGrid1.InitializeLayout Try With e.Layout.Bands(0)
.Columns(.Columns.FromKey("City").Index).Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList .Columns(.Columns.FromKey("City").Index).ValueList.WebCombo = WebCombo1
End With Catch ex As System.Exception Response.Write(ex.Message) End Try End Sub
Private Sub UltraWebGrid1_UpdateCell(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.CellEventArgs) Handles UltraWebGrid1.UpdateCell Try setGrid(e.Cell.Row.Cells(1).Value) Catch ex As System.Exception Response.Write(ex.Message) End Try End Sub
End Class
Never mind, I moved the DataBind() call from UpdateCell to UpdateGrid, and it works OK now.
I too am having this problem. We recently purchased the 9.2 version of Infragistics Software, and I am currently porting the 6.3 version to 9.2. I am using the EXACT same code from 6.3, and EVERY time I try to update a cell, I get the following error:
[NullReferenceException: Object reference not set to an instance of an object.] Infragistics.WebUI.UltraWebGrid.UltraWebGrid.UpdateDBRow(UltraGridRow row, UltraGridRow oldRow) +236 Infragistics.WebUI.UltraWebGrid.UltraWebGrid.ProcessChanges(StateChanges stateChanges, Boolean fireEvents) +1595 Infragistics.WebUI.UltraWebGrid.UltraWebGrid.RaisePostDataChangedEvent() +161 System.Web.UI.Page.RaiseChangedEvents() +165 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1485
This happens EVERY time the grid's UpdateCell method is called. The solution described above does not apply, as I have NO Infragistics controls in the grid. No web date chooser, no web combo, no web calc. Any additional suggestions would be greatly appreciated. I can also post the code if you like. I am really getting frustrated with this, as the code worked fine in the 6.3 version. Why the exact same code in 9.2 doesn't work is beyond me....
Hello,
The code looks fine. Since you are getting this error after upgrading, I would suggest to change syntax when you are attaching the WebCombo to the WebGridColumn.
DAB said: Private Sub UltraWebGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles UltraWebGrid1.InitializeLayout Try With e.Layout.Bands(0) .Columns(.Columns.FromKey("City").Index).Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList .Columns(.Columns.FromKey("City").Index).ValueList.WebCombo = WebCombo1 End With Catch ex As System.Exception Response.Write(ex.Message) End Try End Sub
This following link shows how to do it:
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2009.1/CLR3.5/html/WebGrid_Display_WebCombo_in_a_Cell.html
Let me know if the issue still persists after modifying the syntax.
Thanks,
Sarita
I have encountered a similar problem. I have a very old Infragistics NET Advantage 5.2 web application and I also have newer 7.3 and 8.2 components installed and applications developed. Recently the 5.2 UltraWebGrid's UpdateCell event throws an Object reference not set to an instance of an object error because the event's CellEventArgs parameter named e does not contain any reference in its e.Cell property. I am pretty much sure that the functionality was working OK couple of months ago and I have no idea, if the newer Infragistics components might mess up the older 5.2 components. I have no idea how to resolve this right now, it's a bit of a shame, since updating a grid is a core piece of functionality...