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!
Hi JDawg,
I may be misunderstanding the issue here, but I see 2 possible options:
You can also just remove the "No Data To Display" message.
Let me know if any of this made sense or if this won't work,
Thanks
Jason
Jason Beres"]...2 possible options: Manually add columns in the designer - they will show up at run time when there is no data to display Create a query for the SQL DataSource that just gets the field definition and returns no data, so the column headers show up. Select * from customers where 1 = 0. You can also just remove the "No Data To Display" message....
2 possible options:
...
Thanks for the response Jason. A couple things.1. I had already added the columns in the designer.
2. I need to assign the datasource programmatically, so I'm not working with garden variety datasources by means of drag and drop DataSource controls.
Further explanation of the problem:If I add some code to print out how many rows are returned from the datasource (and hence should be displayed), although there is definitely data present, the UltraWebGrid refuses to display it upon the initial render of the page. If i click on a random page element, such as a radio button and then click back to the default setting, the UltraWebGrid will render with the expected data.
So, for whatever reason, the initial page load will not render the data that is present, but instead returns the "No Data to Display" message, so it's not a case of just wanting the error message to disappear, I need the data that is actually being returned on the initial page load to display, rather than having to coax it by clicking on another random element on the page and back.
Any ideas on how to have it render properly on an initial page load?
TIA,
JD
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.
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?
Sweet! Thank you for the solution!!
Buddy remove the IsBound="True" from each column in WebGrid.
And it will work.
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