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
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 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....