Problem: Can't access the currentselectedrows on the serverside as the data is null?
Server side Code:
Private Sub WebDataGrid1_RowSelectionChanged(sender As Object, e As Infragistics.Web.UI.GridControls.SelectedRowEventArgs) Handles WebDataGrid1.RowSelectionChanged
lbErrorMsge.Text = e.CurrentSelectedRows.Item(0).ToString
End Sub
Error for currentselectedrows line above:
System.NullReferenceException was unhandled by user codeMessage=Object reference not set to an instance of an object.Source=satellitelite_netdocs_appoStackTrace:at satellitelite_netdocs_appo.ManageSystemReporting.WebDataGrid1_RowSelectionChanged(Object sender, SelectedRowEventArgs e) in C:\SatelliteLite2\satellitelite_netdocs_appo\ManageSystemReporting.aspx.vb:line 694at Infragistics.Web.UI.GridControls.Selection.OnRowSelectionChanged(SelectedRowEventArgs e)at Infragistics.Web.UI.GridControls.Selection.RaiseServerEvents()at Infragistics.Web.UI.GridControls.GridBot.RaiseBehaviorServerEvents(GridBehaviorCollection behaviors)at Infragistics.Web.UI.GridControls.GridBot.RaisePostDataChangedEvent()at Infragistics.Web.UI.Framework.RunBot.HandleRaisePostDataChangedEvent()at Infragistics.Web.UI.GridControls.GridBot.HandleRaisePostDataChangedEvent()at Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.RaisePostDataChangedEvent()at System.Web.UI.Page.RaiseChangedEvents()at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)InnerException:
Grid: OnRowSelectionChanged="WebDataGrid1_RowSelectionChanged"
<ig:WebDataGrid ID="WebDataGrid1" runat="server" DataKeyFields="Doc_Id" OnRowSelectionChanged="WebDataGrid1_RowSelectionChanged" AutoGenerateColumns="False" Width="100%" Height="86%" EnableAjax="True">
<EditorProviders> <ig:DropDownProvider ID="WebDataGrid1_DropDownProvider1"> <EditorControl DropDownContainerMaxHeight="200px" EnableAnimations="False" EnableDropDownAsChild="False"> </EditorControl> </ig:DropDownProvider> </EditorProviders> <Behaviors> <ig:Activation> </ig:Activation> <ig:ColumnResizing> </ig:ColumnResizing> <ig:EditingCore> <Behaviors> <ig:CellEditing> </ig:CellEditing> </Behaviors> </ig:EditingCore> <ig:Sorting> </ig:Sorting> <ig:Selection Enabled="true" RowSelectType="Single" CellClickAction="Row"> <AutoPostBackFlags CellSelectionChanged="true" RowSelectionChanged="true" /> </ig:Selection>
<ig:VirtualScrolling> </ig:VirtualScrolling> </Behaviors> </ig:WebDataGrid>
Does anyone know how to solve this issue, ie. retrieve the row details from the server side?
Regards,
Graham.
Thank you
Hello,
WebDataGrid is Aikido (Ajax) based control. It is needed to bind grid on every post back. You may put Data in session object and bind grid to that session also on every post back as shown below:protected void Page_Load(object sender, EventArgs e){if (Session["data"] == null){Session["data"] = getdata();}this.WebDataGrid1.DataSource = Session["data"];this.WebDataGrid1.DataBind();}I was able to find text of the item in cell 1 using below line of code in “RowSelectionChanged” event:
String str=(String) e.CurrentSelectedRows[0].Items[1].Text.ToString();
Hope this helps.
Thanks,
Bhadresh
For info:
I bind the dataset to the grid at runtime in the page load:
If Not Page.IsPostBack Then ' bind dataset to grid. ' etc.End If
Therefore is the data null because the dataset isn't available? If sodo you need to rebind the data on every postback, eg.
If Not Page.IsPostBack Then ' bind dataset to grid. ' etc.
Else ' rebind data for sorting and RowSelectionChanged event??End If