I am using an UltraWebGrid that is being late bound in the page load event. Using Sql Query Profiler I can see that the correct parameters are being passed to my stored procedure and that it is retruning data. Inside the code I can see the WebGrids Initialize Row being hit the correct number of times based on how many rows the stored procedure is returning. The problem is that when the page is actually displayed the WebGrid just shows "No data to display". As soon as you hit the search button on the page the WebGrid starts displaying data as expected.
Relevant Code
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then BindDataToDropDowns() LoadTaxpayerGrid() End Ifend sub
Private Sub LoadTaxpayerGrid() For Each p As Parameter In sdsTaxpayerGrid.SelectParameters looping through the select proc parameters and setting the values to the user entered values the first time through we know there will not be any data and the stored proc accounts for this Next Me.UltraWebGrid1.DataSourceID = Me.sdsTaxpayerGrid.UniqueID Me.UltraWebGrid1.DataBind()End Sub
Private Sub UltraWebGrid1_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.RowEventArgs) Handles UltraWebGrid1.InitializeRow Masking some of the columnsEnd Sub
The relevant markup
<igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" EnableAppStyling="True" StyleSetName="Nautilus"> <Bands> <igtbl:UltraGridBand> <Columns> </Columns> <AddNewRow View="NotSet" Visible="NotSet"> </AddNewRow> </igtbl:UltraGridBand> </Bands> <DisplayLayout> </DisplayLayout></igtbl:UltraWebGrid>
<asp:SqlDataSource ID="sdsTaxpayerGrid" runat="server" ConnectionString="<%$ ConnectionStrings:EfilingConnectionString %>" SelectCommand="EAccount_GetTaxPayerInfoForGrid" SelectCommandType="StoredProcedure" CancelSelectOnNullParameter="False" > <SelectParameters> <asp:SessionParameter Name="MAILBOX" SessionField="MAILBOX" Type="String" /> <asp:Parameter Name="SSN" Type="String" DefaultValue="" ConvertEmptyStringToNull="true" /> <asp:Parameter Name="FNAME" Type="String" DefaultValue="" ConvertEmptyStringToNull="true" /> <asp:Parameter Name="LNAME" Type="String" DefaultValue="" ConvertEmptyStringToNull="true" /> <asp:Parameter Name="RALQIKCODE" Type="String" DefaultValue="" ConvertEmptyStringToNull="true" /> <asp:Parameter Name="ACCPTCODE" Type="String" DefaultValue="" ConvertEmptyStringToNull="true" /> <asp:Parameter Name="NTSRSN" Type="String" DefaultValue="" ConvertEmptyStringToNull="true" /> <asp:Parameter Name="IRSCENTER" Type="String" DefaultValue="" ConvertEmptyStringToNull="true" /> <asp:Parameter Name="DCN" Type="String" DefaultValue="" ConvertEmptyStringToNull="true" /> <asp:Parameter Name="PROCSTAT" Type="String" DefaultValue="" ConvertEmptyStringToNull="true" /> <asp:Parameter Name="DIRSTATE" Type="String" DefaultValue="" ConvertEmptyStringToNull="true" /> <asp:Parameter Name="PIGGYSTATE" Type="String" DefaultValue="" ConvertEmptyStringToNull="true" /> <asp:Parameter Name="ROWCOUNT" Type="int32" DefaultValue="20"/> </SelectParameters></asp:SqlDataSource>
check the AutoGenerateColumns property.
It should be true to do that
Ok, so is there a viable solution for someone who is very particular about which columns are displayed and does not want to AutoGenerateColumns?
i.e. Is there a workaround that avoids both the annoyance of the "No Data to Display"error message (when there is, in fact data to display) and when auto-generating the columns is out of the question?
Thanks!
Hello JD,
Can you post the page that you are running this issue with? I cannot think of any reason why the grid would fail to show the data during first load, but will show data if you click on a random element on the page.
One thing I would like you to check is to try binding your data to the GridView in the same way you are binding it to the WebGrid, and see if you see data during the initial load in the GridView. If you do, then this probably maybe a bug that we need to look into. In any case, if you attach a sample, that might help us determine what is going on and we can go from there.
Thanks, Taz.
Hi Taz,
Thank you for your suggestions. The GridView does work during the initial load, while the WebGrid fails. Here is a sample:
Imports System Imports System.Configuration Imports System.Data Imports System.Data.SqlClient Imports System.Web Imports Infragistics.WebUI.UltraWebGrid Imports GESlsOrd Namespace GESlsOrd Partial Class WebGridTest Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim Acct As String = "413000" Dim Part As String = "CRYD2425D" If (rdoOrderListing.SelectedValue = "Closed") Then 'GridView gvOrderListing_Open.Visible = False gvOrderListing_Closed.Visible = True gvOrderListing_Closed.DataSource = SlsOrdData.PHOrderListing_Closed(Acct, Part) 'DataTable gvOrderListing_Closed.DataBind() 'UltraWebGrid UwgOrderListing_Open.Visible = False UwgOrderListing_Closed.Visible = True UwgOrderListing_Closed.DataSource = SlsOrdData.PHOrderListing_Closed(Acct, Part) 'DataTable UwgOrderListing_Closed.DataBind() Else ' If (rdoOrderListing.SelectedValue = "Open") Then 'GridView gvOrderListing_Closed.Visible = False gvOrderListing_Open.Visible = True gvOrderListing_Open.DataSource = SlsOrdData.PHOrderListing_Open(Acct, Part) 'DataTable gvOrderListing_Open.DataBind() 'UltraWebGrid UwgOrderListing_Closed.Visible = False UwgOrderListing_Open.Visible = True UwgOrderListing_Open.DataSource = SlsOrdData.PHOrderListing_Open(Acct, Part) 'DataTable UwgOrderListing_Open.DataBind() End If End Sub End Class End Namespace
Buddy remove the IsBound="True" from each column in WebGrid.
And it will work.
I am having the same problem, the only difference is that the "No Data To Display" are is not displayed all the time. It happens randomly, so much so that I cannot reproduce the issue to pin it down. The solution provided here will probably not work for me. I am saying this because a quick search for the IsBound did not return anything. Is there any fundamental reason behind this behaiver?
I have the same problem now, I am trying to upgrade by infragistics controls from 2011vol2 to Infragistics 2013 Vol3. When I load the data first time it is not showing any records, if I refresh or reload data I see all the data properly.