This is a migrated thread and some comments may be shown as answers.

RadGrid not displaying data available in NeedDataSource event

1 Answer 225 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bruce
Top achievements
Rank 1
Bruce asked on 25 Mar 2011, 01:18 AM
All,

I am having an issue displaying data in my grid using Telerik AJAX controls v. 2010.3.1317.35. I have no idea why, as numerous other grids in other user controls on the same page are displaying fine. I can see in my NeedDataSource event that the oARAC collection object has data, and that the column name in the query is correct in the grid column. I can also see the grid shows 2 empty rows, so for some reason the grid is interpreting the data "4999220" as  

I have confirmed that the NeedDataSource event is not firing twice when loaded, and I am not getting any exceptions.

Below is the code, and attached are the images of what is going on as I debug.

Any and all help is greatly appreciated!

Thanks,
Bruce
       
protected void rgApplications_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    LaundryLogicDAL.ARApplicationsCollection oARAC = new LaundryLogicDAL.ARApplicationsCollection();
 
    LaundryLogicDAL.ARApplicationsQuery oARAQ = new LaundryLogicDAL.ARApplicationsQuery("ara");
    LaundryLogicDAL.ARCreditsQuery oARCQ = new LaundryLogicDAL.ARCreditsQuery("arc");
    LaundryLogicDAL.ARDebitsQuery oARDQ = new LaundryLogicDAL.ARDebitsQuery("ard");
 
    try
    {
        oARAC.es.Connection.Name = "NAS";
        oARAC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
        oARAQ.es2.Connection.Name = "NAS";
        oARAQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
        oARCQ.es2.Connection.Name = "NAS";
        oARCQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
        oARDQ.es2.Connection.Name = "NAS";
        oARDQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
 
        oARAQ.Select(
            oARCQ.CreditIdentifier,
            oARCQ.CreditDate,
            oARCQ.OriginalAmount.As("CreditAmount"),
            oARAQ.ApplicationDate,
            oARAQ.Amount.As("ApplicationAmount"),
            oARAQ.Notes.As("ApplicationNotes"),
            oARDQ.DebitIdentifier,
            oARDQ.DebitDate,
            oARDQ.OriginalAmount.As("DebitAmount")
            );
        oARAQ.InnerJoin(oARCQ).On(
            oARAQ.CreditID == oARCQ.Id);
        oARAQ.InnerJoin(oARDQ).On(
            oARAQ.DebitID == oARDQ.Id);
 
        //if (Session["DebitID"] != null)
        if (ViewState["DebitID"] != null && (int)ViewState["DebitID"] >= 0)
        {
            oARAQ.Where(
                //oARAC.Query.DebitID == (int)Session["DebitID"]
                oARAQ.DebitID == (int)ViewState["DebitID"]
                );
        }
        else if (ViewState["CreditID"] != null && (int)ViewState["CreditID"] >= 0)
        {
            oARAQ.Where(
                //oARAC.Query.DebitID == (int)Session["DebitID"]
                oARAQ.DebitID == (int)ViewState["CreditID"]
                );
        }
 
        if (oARAC.Load(oARAQ))      
        {
            rgApplications.DataSource = oARAC;
        }
        else
        {
            rgApplications.DataSource = new object[0];
        }
    }
    catch(Exception ex)
    {
        rgApplications.DataSource = new object[0];
        DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
    }
    finally
    {
        oARAC.Dispose();
        oARAC = null;
        oARAQ = null;
        oARCQ = null;
        oARDQ = null;
    }
}

<telerik:RadGrid ID="rgApplications" runat="server" AllowFilteringByColumn="True"
    AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" GridLines="None"
    OnNeedDataSource="rgApplications_NeedDataSource">
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
    </HeaderContextMenu>
    <MasterTableView AllowMultiColumnSorting="True">
        <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridBoundColumn DataField="CreditIdentifier" FilterControlAltText="Filter CreditIdentifier column"
                HeaderText="Credit ID" UniqueName="CreditIdentifier">
            </telerik:GridBoundColumn>
        </Columns>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
</telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Bruce
Top achievements
Rank 1
answered on 25 Mar 2011, 01:46 AM
All,

Nevermind...

What was happening was the grid could not use the collection based on the query. It could not locate the field even though it was being returned. Using GridBoundColumn just ignored the fact that it couldn't find the field in the collection. The only reason I discovered this issue was by changing the column to a template column. Once it was a template column it threw an exception.

My workaround was to load the query into a datatable instead of the collection and use the datatable as the source.

Thanks,
Bruce
Tags
Grid
Asked by
Bruce
Top achievements
Rank 1
Answers by
Bruce
Top achievements
Rank 1
Share this question
or