Experts, there is something very basic I'm missing here. I've read literally hundreds of posts of similar questions, and I'm still not understanding.
I have a WebDataGrid using an ObjectDataSource for its data. On the initial page load as well as every postback, the Selecting event of the ObjectDataSource is being fired, therefore calling SQL Server for new data. I thought by setting the EnableDataViewState='true", the grid would not request data on a postback unless I told it to. I can't determine if the grid is actually requesting data, or is the selecting event of the ObjectDataSource is firing by itself. I've tried several scenarios with, and without an update panel, but can't seem to figure out how to get the ObjectDataSource from selecting data on a PostBack, or an Ajax PostBack until I want it to.
I've tried regular ObectDataSource parameters, as well as session parameters to no avail.
On the production code I have several update panels, with several grids. Every time there is a postback, all the ObjectDataSources are requesting data causing significant performance issues.
Any ideas of what I'm missing?
Thanks
Simple Example
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="CommitmentBooksPortal.test" %> <%@ Register Assembly="Infragistics45.Web.v17.2, Version=17.2.20172.1006, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.Web.UI.GridControls" TagPrefix="ig" %> <%@ Register Assembly="Infragistics45.Web.v17.2, Version=17.2.20172.1006, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.Web.UI.LayoutControls" TagPrefix="ig" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <asp:Button ID="Button1" runat="server" Text="PostBack" OnClick="Button1_Click" /> <ig:WebDataGrid ID="WebDataGridStoreFilter" runat="server" Height="470px" Width="400px" DataKeyFields="Sys_ID" AutoGenerateColumns="False" DataSourceID="ObjectDataSourceStoreFilter" ShowFooter="false" EnableAjax="false" EnableAjaxViewState="false" EnableViewState="true" EnableDataViewState="true"> <AjaxIndicator Enabled="false" /> <Columns> <ig:BoundDataField Key="Sys_ID" DataFieldName="Sys_ID" Hidden="true"> <Header Text="SYS_ID"></Header> </ig:BoundDataField> <ig:BoundCheckBoxField CssClass="FilterCheckBox" Key="Filter" DataFieldName="Filter"> <Header Text="FIL"></Header> </ig:BoundCheckBoxField> <ig:BoundDataField Key="Store_Num" DataFieldName="Store_Num" Width="50px" CssClass="filterFieldStoreNum"> <Header Text="Store"></Header> </ig:BoundDataField> <ig:BoundDataField Key="Store_Name" DataFieldName="Store_Name" Width="250px"> <Header Text="Name"></Header> </ig:BoundDataField> </Columns> <Behaviors> <ig:EditingCore Enabled="true" BatchUpdating="true"> <EditingClientEvents /> <Behaviors> <ig:CellEditing Enabled="true"> <ColumnSettings> <ig:EditingColumnSetting ReadOnly="false" ColumnKey="Filter" /> </ColumnSettings> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors> </ig:WebDataGrid> <asp:ObjectDataSource ID="ObjectDataSourceStoreFilter" runat="server" SelectMethod="selectStoreFilter" TypeName="CommitmentBooksPortal.clsDefaultDataAccessLayer" UpdateMethod="updateStoreFilter" OnSelecting="ObjectDataSourceStoreFilter_Selecting"> <SelectParameters> <asp:Parameter Name="UserId" Type="String" /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="Sys_ID" Type="Int32" /> <asp:Parameter Name="Filter" Type="Boolean" /> </UpdateParameters> </asp:ObjectDataSource> </asp:Content>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CommitmentBooksPortal { public partial class test : basepage { protected void Page_Load(object sender, EventArgs e) { } protected void ObjectDataSourceStoreFilter_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { clsCommonClassWrapper clsCCW = (clsCommonClassWrapper)HttpContext.Current.Session["clsCCW"]; if (clsCCW == null) { clsCCW = new clsCommonClassWrapper(); } e.InputParameters["UserId"] = clsCCW.clsIAS.UserId; } protected void Button1_Click(object sender, EventArgs e) { } } }
Hello Fred,
Thank you for the detailed description and the code-snippet you have provided.
The behavior you have described in regards to having the Selecting event of the ObjectDataSource fired on every post-back for the WebDataGrid with EnableDataViewState set to true has been fixed in the latest Service Release for the ASP.NET product. Presuming you are using ASP.NET 17.2, the SR build for this version is 17.2.20172.2123.
Would you please test the behavior you have described by using the lastest SR build and see if the issue is still reproduced?
To download the latest service release follow these steps:
1. View My Keys and Downloads: https://www.infragistics.com/my-account/keys-and-downloads2. Log in to the Infragistics web site if you are not already logged in.3. Select the product you would like to download a service release for.4. Select the “Service Releases” tab.5. Select the download (e.g. Infragistics ASP.NET 2017 Vol. 2 - Service Release)
If you have any questions, please let me know.
Tacho,
I upgraded to the latest 2017 release and see the same behavior
I then upgraded to the latest release of 2018 and still the same thing is happening
namespace CommitmentBooksPortal { public partial class test : basepage { protected void Page_Load(object sender, EventArgs e) { } protected void ObjectDataSourceStoreFilter_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { clsCommonClassWrapper clsCCW = (clsCommonClassWrapper)HttpContext.Current.Session["clsCCW"]; if (clsCCW == null) { clsCCW = new clsCommonClassWrapper(); } e.InputParameters["UserId"] = clsCCW.clsIAS.UserId; } protected void Button1_Click(object sender, EventArgs e) { } } }
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="CommitmentBooksPortal.test" %> <%@ Register Assembly="Infragistics45.Web.v18.1, Version=18.1.20181.70, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.Web.UI.GridControls" TagPrefix="ig" %> <%@ Register Assembly="Infragistics45.Web.v18.1, Version=18.1.20181.70, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.Web.UI.LayoutControls" TagPrefix="ig" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <asp:Button ID="Button1" runat="server" Text="PostBack" OnClick="Button1_Click" /> <ig:WebDataGrid ID="WebDataGridStoreFilter" runat="server" Height="470px" Width="400px" DataKeyFields="Sys_ID" AutoGenerateColumns="False" DataSourceID="ObjectDataSourceStoreFilter" ShowFooter="false" EnableAjax="false" EnableAjaxViewState="false" EnableViewState="true" EnableDataViewState="true"> <AjaxIndicator Enabled="false" /> <Columns> <ig:BoundDataField Key="Sys_ID" DataFieldName="Sys_ID" Hidden="true"> <Header Text="SYS_ID"></Header> </ig:BoundDataField> <ig:BoundCheckBoxField CssClass="FilterCheckBox" Key="Filter" DataFieldName="Filter"> <Header Text="FIL"></Header> </ig:BoundCheckBoxField> <ig:BoundDataField Key="Store_Num" DataFieldName="Store_Num" Width="50px" CssClass="filterFieldStoreNum"> <Header Text="Store"></Header> </ig:BoundDataField> <ig:BoundDataField Key="Store_Name" DataFieldName="Store_Name" Width="250px"> <Header Text="Name"></Header> </ig:BoundDataField> </Columns> <Behaviors> <ig:EditingCore Enabled="true" BatchUpdating="true"> <EditingClientEvents /> <Behaviors> <ig:CellEditing Enabled="true"> <ColumnSettings> <ig:EditingColumnSetting ReadOnly="false" ColumnKey="Filter" /> </ColumnSettings> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors> </ig:WebDataGrid> <asp:ObjectDataSource ID="ObjectDataSourceStoreFilter" runat="server" SelectMethod="selectStoreFilter" TypeName="CommitmentBooksPortal.clsDefaultDataAccessLayer" UpdateMethod="updateStoreFilter" OnSelecting="ObjectDataSourceStoreFilter_Selecting"> <SelectParameters> <asp:Parameter Name="UserId" Type="String" /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="Sys_ID" Type="Int32" /> <asp:Parameter Name="Filter" Type="Boolean" /> </UpdateParameters> </asp:ObjectDataSource> </asp:Content>
Thoughts?
Thank you for the feedback.
I have attached a sample application that is based on the settings you have used and the OnSelecting event of the ObjectDataSource is fired only at the initial page load.In order to test this, I have created an asp button that generates post-backs and clicking it does not fire the OnSelecting event. (Note that this behavior is tested with the latest 17.2 SR - 17.2.20172.2123)
Would you please modify the sample so the issue is reproduced and send it back to me? Having this information will help me further investigate this matter for you.
6431.WebDataGrid_sample_objectDataSource.zip
Hello Tacho,
I verified your sample works. After some testing I found that the BoundCheckBoxField is causing the issue. I added a BoundCheckBoxField to your example and the ObjectDataSource selects on each postback. When I remove the column, this stops. Updated Sample Attached. Is there anyway to work around this?
UpdatedExample.zip
Thank you for the sample application you have provided.
I have investigated your issue, and I have asked our engineering staff to examine this further. I have logged this behavior in our internal tracking system with a Development ID of 258194. This will be assigned to a developer in a future sprint to review my investigation and confirm my findings or to offer a fix, or other resolution.