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
385
WebGrid Issue with Value List on PostBack
posted

Hi,

I'm having a problem with a simple webgrid.  There are about 20 columns and many of them are dropdown lists that are populated in the  UltraWebGrid1_InitializeLayout event.  I call individual subs like this for all the dropdowns:

<code>

Private Sub InitializeComponents()

        Dim ComponentCmbAdapt As New SqlDataAdapter(spComponent, ConnString)
        Dim ComponentCmbTable As New DataTable("ComponentCombo")
        Dim ComponentRow As  DataRow
        Dim ComponentValuelist As New Infragistics.WebUI.UltraWebGrid.ValueList

        ComponentCmbAdapt.Fill(ComponentCmbTable)

        UltraWebGrid1.Columns(3).Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList

        For Each ComponentRow In ComponentCmbTable.Rows

            ComponentValuelist.ValueListItems.Add(ComponentRow("componentDesc").ToString())
            Me.UltraWebGrid1.DisplayLayout.Bands(0).Columns(3).ValueList = ComponentValuelist
        Next

End Sub

<code>

 

When the grid loads with the records the database, all is well.  However, the users want to be able to update information directly on this grid.  So, I use this event: UltraWebGrid1_UpdateRow.  When I come off the row after updating a field, this error pops up:

<error>

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:

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. 

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
   Infragistics.WebUI.UltraWebGrid.ValueListItemsCollection.System.Web.UI.IStateManager.LoadViewState(Object savedState) +563
   Infragistics.WebUI.UltraWebGrid.ValueList.System.Web.UI.IStateManager.LoadViewState(Object savedState) +260
   Infragistics.WebUI.UltraWebGrid.UltraGridColumn.LoadViewState(Object savedState) +353
   Infragistics.WebUI.UltraWebGrid.UltraGridColumn.System.Web.UI.IStateManager.LoadViewState(Object savedState) +32
   Infragistics.WebUI.UltraWebGrid.ColumnsCollection.System.Web.UI.IStateManager.LoadViewState(Object savedState) +2665
   Infragistics.WebUI.UltraWebGrid.UltraGridBand.System.Web.UI.IStateManager.LoadViewState(Object savedState) +795
   Infragistics.WebUI.UltraWebGrid.BandsCollection.System.Web.UI.IStateManager.LoadViewState(Object savedState) +586
   Infragistics.WebUI.UltraWebGrid.UltraGridLayout.System.Web.UI.IStateManager.LoadViewState(Object savedState) +1131
   Infragistics.WebUI.UltraWebGrid.UltraWebGrid.LoadViewState(Object savedState) +339
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +186
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +136
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +224
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +136
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +224
   System.Web.UI.Page.LoadAllState() +439
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1092

</error>

I have isolated the issue to the dropdown items because if I comment them all out, no issues with the update - but I need the dropdowns!


I know this is an issue with the postback and viewstate, but I'm not sure what to do to get around it.  I tried using :

If Not (Page.IsPostBack) Then....

but it doesn't help.  Am I not initializing something correctly?

I appreciate any guidance, this is the main functionality they want and I can't seem to get it to work

Thanks!

JCC

Parents
No Data
Reply Children
No Data