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!