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>
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.
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:
You can also just remove the "No Data To Display" message.
...
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
Hi JDawg,
I may be misunderstanding the issue here, but I see 2 possible options:
Let me know if any of this made sense or if this won't work,
Thanks
Jason
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!
check the AutoGenerateColumns property.
It should be true to do that