An item with the same key has already been added

28 posts, 0 answers
  1. BILLY ALLEN
    BILLY ALLEN avatar
    10 posts
    Member since:
    Dec 2008

    Posted 12 Dec 2008 Link to this post

    I've got a radGrid that allows in-place editing.   After the user makes changes to the row, and presses the CommandButton.Update button to commit the change, the following error message displays:

    Sys.WebForms.PageRequestManagerServerErrorException:  An item with the same key has already been added.

    I don't think we were getting this error until we replaced our demo version of Telerik asp.net controls with the purchased version this week. 

    Interestingly, the row does in fact get persisted to the database.  However, this error is causing the row to stay in Edit mode.

    Anyone else have this problem?  Any suggestions as to what I may be doing wrong?

    Thanks!
  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 15 Dec 2008 Link to this post

    Hello,

    Could you please elaborate a bit more on your scenario? Is it possible the problematic to have column with duplicate DataField? If you could share your grid declaration and any connected server code could help us provide a resolution for you. 

    Sincerely yours,
    Iana
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. BILLY ALLEN
    BILLY ALLEN avatar
    10 posts
    Member since:
    Dec 2008

    Posted 15 Dec 2008 Link to this post

    Thanks -- here's the Grid declaration.  Let me know if you see something amiss.

    <

     

    telerik:RadGrid

     

     

    ID="grdDocClaims"

     

     

    runat="server"

     

     

    Skin="Vista"

     

     

    AllowPaging="true"

     

     

    AllowSorting="true"

     

     

    AutoGenerateColumns="false"

     

     

    GridLines="None"

     

     

    AllowMultiRowEdit="false"

     

     

    ClientSettings-Selecting-AllowRowSelect="true"

     

     

    ClientSettings-Selecting-EnableDragToSelectRows="false"

     

     

    PagerStyle-Mode="NextPrevNumericAndAdvanced"

     

     

    OnNeedDataSource="onNeedClaimDataSource"

     

     

    OnItemDataBound="grdDocClaims_ItemDataBound"

     

     

    OnUpdateCommand="grdDocClaims_Update"

     

     

    PageSize="11"

     

     

    ShowFooter="true"

     

     

    >

     

     

    <PagerStyle Mode="NextPrevNumericAndAdvanced" />

     

     

    <MasterTableView

     

     

    EditMode="InPlace"

     

     

    ClientDataKeyNames="documentActivityID" >

     

     

    <RowIndicatorColumn>

     

     

    <HeaderStyle Width="20px" />

     

     

    </RowIndicatorColumn>

     

     

    <ExpandCollapseColumn>

     

     

    <HeaderStyle Width="20px" />

     

     

    </ExpandCollapseColumn>

     

     

    <Columns>

     

     

    <telerik:GridBoundColumn

     

     

    UniqueName="col_claimDocumentActivityID"

     

     

    ReadOnly="true"

     

     

    Display="false"

     

     

    DataField="documentActivityID"

     

     

    />

     

     

    <telerik:GridBoundColumn

     

     

    DataField="activityName"

     

     

    SortExpression="activityName"

     

     

    ReadOnly="true"

     

     

    HeaderText="Activity"

     

     

    UniqueName="col_claimActivityName"

     

     

    ItemStyle-HorizontalAlign="Left"

     

     

    FooterText="Totals"

     

     

    >

     

     

    </telerik:GridBoundColumn>

     

     

    <telerik:GridBoundColumn

     

     

    DataField="subDisciplineName"

     

     

    SortExpression="subDisciplineName"

     

     

    ReadOnly="true"

     

     

    HeaderText="Sub Discipline"

     

     

    UniqueName="col_claimSubDisciplineName"

     

     

    ItemStyle-HorizontalAlign="Left">

     

     

    </telerik:GridBoundColumn>

     

     

    <telerik:GridBoundColumn

     

     

    DataField="costCodeFullName"

     

     

    SortExpression="costCodeFullName"

     

     

    ReadOnly="true"

     

     

    HeaderText="Cost Code"

     

     

    UniqueName="col_claimCostCodeFullName"

     

     

    ItemStyle-HorizontalAlign="Left">

     

     

    </telerik:GridBoundColumn>

     

     

    <telerik:GridBoundColumn

     

     

    DataField="invoiceFullName"

     

     

    SortExpression="invoiceFullName"

     

     

    ReadOnly="true"

     

     

    HeaderText="Invoice #"

     

     

    UniqueName="col_claimInvoiceFullName"

     

     

    EmptyDataText="What?"

     

     

    ItemStyle-HorizontalAlign="Left">

     

     

    </telerik:GridBoundColumn>

     

     

    <telerik:GridBoundColumn

     

     

    DataField="mhf"

     

     

    SortExpression="mhf"

     

     

    ReadOnly="true"

     

     

    HeaderText="MHF"

     

     

    UniqueName="col_claimMHS"

     

     

    ItemStyle-HorizontalAlign="Right"

     

     

    HeaderStyle-HorizontalAlign="Right"

     

     

    >

     

     

    </telerik:GridBoundColumn>

     

     

    <telerik:GridBoundColumn

     

     

    Aggregate="Sum"

     

     

    DataField="qty"

     

     

    HeaderText="Qty"

     

     

    DataFormatString="{0:N2}"

     

     

    FooterAggregateFormatString="{0:N2}"

     

     

    FooterText="Total Qty: "

     

     

    ReadOnly="true"

     

     

    UniqueName="col_claimQty"

     

     

    FooterStyle-HorizontalAlign="Right"

     

     

    ItemStyle-HorizontalAlign="Right"

     

     

    HeaderStyle-HorizontalAlign="Right"

     

     

    >

     

     

    </telerik:GridBoundColumn>

     

     

    <telerik:GridBoundColumn

     

     

    Aggregate="sum"

     

     

    DataField="budgetedManHours"

     

     

    HeaderText="Budget Hours"

     

     

    DataFormatString="{0:N2}"

     

     

    ReadOnly="true"

     

     

    UniqueName="col_claimBudgetManHours"

     

     

    FooterAggregateFormatString="{0:N2}"

     

     

    FooterText="Total Hours: "

     

     

    FooterStyle-HorizontalAlign="Right"

     

     

    ItemStyle-HorizontalAlign="Right"

     

     

    HeaderStyle-HorizontalAlign="Right"

     

     

    >

     

     

    </telerik:GridBoundColumn>

     

     

    <telerik:GridCalculatedColumn

     

     

    HeaderText="Hours Remain"

     

     

    UniqueName="col_claimHoursLeft"

     

     

    DataType="System.Double"

     

     

    DataFields="budgetedManHours, percentage"

     

     

    Expression="iif({1}=0, {0}, {0}* ((100-{1})/100) )"

     

     

    DataFormatString="{0:N2}"

     

     

    ItemStyle-HorizontalAlign="Right"

     

     

    HeaderStyle-HorizontalAlign="Right"

     

     

    Aggregate="Sum"

     

     

    FooterAggregateFormatString="{0:N2}"

     

     

    FooterStyle-HorizontalAlign="Right"

     

     

    >

     

     

    </telerik:GridCalculatedColumn>

     

     

     

    <telerik:GridTemplateColumn

     

     

    UniqueName="col_claimDateCompleted"

     

     

    ItemStyle-HorizontalAlign="Right"

     

     

    HeaderStyle-HorizontalAlign="Right"

     

     

    >

     

     

    <HeaderTemplate>

     

     

    <asp:Label ID="lblClaimDateComplete"

     

     

    Text="Date Complete"

     

     

    runat="server">

     

     

    </asp:Label>

     

     

    </HeaderTemplate>

     

     

    <ItemTemplate>

     

     

    <asp:Label ID="lblClaimDateComplete2"

     

     

    runat="server"

     

     

    Text='<%# Eval("dateCompleted","{0:d}") %>'>

     

     

    </asp:Label>

     

     

    </ItemTemplate>

     

     

    <EditItemTemplate>

     

     

    <telerik:RadDatePicker

     

     

    ID="lookupClaimDateCompleted"

     

     

    runat="server"

     

     

    Calendar-ShowRowHeaders="false"

     

     

    SelectedDate='<%# getADate(Eval("dateCompleted")) %>'

     

     

    Skin="Vista"

     

     

    width="90px">

     

     

    </telerik:RadDatePicker>

     

     

    </EditItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

     

    <telerik:GridTemplateColumn

     

     

    UniqueName="col_claimRule"

     

     

    ItemStyle-HorizontalAlign="Right"

     

     

    HeaderStyle-HorizontalAlign="Right"

     

     

    >

     

     

    <HeaderTemplate>

     

     

    <asp:Label ID="Label1"

     

     

    Text="Done"

     

     

    runat="server">

     

     

    </asp:Label>

     

     

    </HeaderTemplate>

     

     

    <ItemTemplate>

     

     

    <asp:Label ID="lblClaimRule"

     

     

    runat="server"

     

     

    Text='<%# Eval("percentage","{0:N0}%") %>'>

     

     

    </asp:Label>

     

     

    </ItemTemplate>

     

     

    <EditItemTemplate>

     

     

    <telerik:RadComboBox

     

     

    ID="lookupClaimingRules"

     

     

    runat="server"

     

     

    DataTextField="ruleName"

     

     

    DataValueField="ruleID"

     

     

    Skin="Vista"

     

     

    Width="85px"

     

     

    >

     

     

    </telerik:RadComboBox>

     

     

    </EditItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    <telerik:GridEditCommandColumn

     

     

    UniqueName="ClaimEditCommandColumn"

     

     

    ButtonType="ImageButton"

     

     

    UpdateImageUrl="/images/grid/update.gif"

     

     

    CancelImageUrl="/images/grid/cancel.gif"

     

     

    EditImageUrl="/images/grid/edit.gif"

     

     

    />

     

     

    </Columns>

     

     

    </MasterTableView>

     

     

    <ClientSettings

     

     

    AllowColumnsReorder="true"

     

     

    ReorderColumnsOnClient="true"

     

     

    >

     

     

    </ClientSettings>

     

     

    </telerik:RadGrid>

     

  5. BILLY ALLEN
    BILLY ALLEN avatar
    10 posts
    Member since:
    Dec 2008

    Posted 15 Dec 2008 Link to this post

    Interesting -- I removed the "calculated" columns from the definition, and the problem goes away!  What is it about these three columns that cause a problem?

     edit:  it's this specific column causing the problem.  What is wrong with my definition?

     

    <telerik:GridCalculatedColumn

    Aggregate="Sum"

    DataFields="budgetedManHours, percentage"

    HeaderText="Hours Remain"

    UniqueName="col_claimHoursLeft"

    DataType="System.Double"

    Expression="iif({1}=0, {0}, {0}* ((100-{1})/100) )"

    DataFormatString="{0:N2}"

    ItemStyle-HorizontalAlign="Right"

    HeaderStyle-HorizontalAlign="Right"

    FooterAggregateFormatString="{0:N2}"

    FooterStyle-HorizontalAlign="Right"

    >

    </telerik:GridCalculatedColumn>

  6. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 16 Dec 2008 Link to this post

    Hi BILLY,

    Thank you for sharing your code.

    Your grid declaration and the declaration of the GridCalculatedColumn looks fine to me. However I will have to perform additional investigation on the issue. Are you working under .Net 2.0 or .Net 3.5?
     
    Additionally, can you try uncommenting the GridCalculatedColumn and commenting the column with UniqueName col_claimBudgetManHours and see if the error persists?

    Kind regards,
    Iana
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. BILLY ALLEN
    BILLY ALLEN avatar
    10 posts
    Member since:
    Dec 2008

    Posted 16 Dec 2008 Link to this post

    Thanks Lana,

    I uncommented the GridCalcColumn, and commented out col_claimBudgetManHours.  The problem remains.  I tried all sorts of combinations, it seems the problem only exists when the GridCalculatedColumn is present.  It does display properly in view mode and while editing.

    I looked at my project, and the Target Framework is .Net 3.5.

    I hope this information helps you figure out what's going on.  For now, I have commented out the column, hopefully my users can live with it for a little while.

  8. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 17 Dec 2008 Link to this post

    Hello BILLY,

    I prepared a sample project in order to test the issue you are facing. But the calculated column works as expected on my end. Can you check the attached sample and let me know what differs in your case?

    Thank you for your cooperation in advance.

    Regards,
    Iana
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. BILLY ALLEN
    BILLY ALLEN avatar
    10 posts
    Member since:
    Dec 2008

    Posted 17 Dec 2008 Link to this post

    Thanks for your reply.

    Your project is very simple compared to mine.  My project uses a master page, a lot of AJAX stuff, and the particular page it's on has a tab control inside of a radPane.  So maybe some other component interactions are causing the problem.  As a guess, I removed the AjaxManagerProxy (the radajaxmanager is on the master page).  Instead of a javascript error, I got a good ASP.Net error, with the following.  Maybe it will help tracking it down?

    [ArgumentException: An item with the same key has already been added.]
       System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +51
       System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +7460188
       System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) +11
       Telerik.Web.UI.GridDataTableFromEnumerable.FillData() +4293
       Telerik.Web.UI.GridResolveEnumerable.Initialize() +55
       Telerik.Web.UI.GridResolveEnumerable.EnsureInitialized() +40
       Telerik.Web.UI.GridResolveEnumerable.get_DataTable() +31
       Telerik.Web.UI.GridEnumerableFromDataView..ctor(GridTableView owner, DataView dataView, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +222
       Telerik.Web.UI.GridDataSourceHelper.CreateGridEnumerable(GridTableView owner, IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +97
       Telerik.Web.UI.GridDataSourceHelper.GetResolvedDataSource(GridTableView owner, Object dataSource, String dataMember, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +556
       Telerik.Web.UI.GridTableView.get_ResolvedDataSource() +219
       Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +73
       System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
       System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
       System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
       System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
       Telerik.Web.UI.GridTableView.PerformSelect() +28
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
       Telerik.Web.UI.GridTableView.DataBind() +365
       Telerik.Web.UI.GridTableView.Rebind() +98
       Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source) +2084
       Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +191
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +165
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e) +111
       System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +176
       System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
    

    I do know that it works without any problems if I remove the GridCalculatedColumn.  I am working around it by simply commenting out the column, but I am sure my users will notice the missing column.  If I have to, I'll calculate it in SQL and avoid the column entirely.

  10. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 19 Dec 2008 Link to this post

    Hi,

    From the stack trace you send me I can see that error is thrown after grid command is fired. But could you clarify if this is insert/edit or some other operation?
    Also, check if setting the EnableLinqExpressions property of the grid to false helps.
    Additionaly, I suggest that you send me the server-side code of the problematic page.

    All the best,
    Iana
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  11. BILLY ALLEN
    BILLY ALLEN avatar
    10 posts
    Member since:
    Dec 2008

    Posted 19 Dec 2008 Link to this post

    Thanks Iana,

    I tried setting EnableLinqExpressions=true in the grid definition, but the error remains.

    I have removed the column and am doing the calculation in sql instead of using a gridCalculatedColumn.  So, there's definitely a problem in there somewhere, but I am avoiding it. 

    Oh yeah -- we're editing rows, not inserting new data.

  12. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 19 Dec 2008 Link to this post

    Hello,

    Indeed, the default value of the EnableLinqExpressions property of the grid is true. I am more interested in what happens if it is false.
    However you have found a solution now, if you have time in future, you can open a formal support ticket and send us the problematic page so we could investigate the issue in depth and get to the source of the issue.

    Thank you for your cooperation in advance.

    Greetings,
    Iana
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  13. Raj
    Raj avatar
    18 posts
    Member since:
    Aug 2008

    Posted 26 Dec 2008 Link to this post

    Try executing the following code after update :

    grid.DataSource = null;
    grid.Rebind();

  14. Zeke Sheppard
    Zeke Sheppard avatar
    32 posts
    Member since:
    Oct 2009

    Posted 28 Jan 2010 Link to this post

    Was this problem ever resolved in the control? I am also getting the same error when paging is enabled in a grid with a GridCalculatedColumn. Removing the column eliminates the issue but that column needs to be in the grid.

    Also, it appear setting the pagesize property to a value greater than 10 caused the footer to not be displayed.

    This control (as well as other Telerik controls) have been a real nightmare to use in anything except the most simple implementation. So buggy!
  15. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 01 Feb 2010 Link to this post

    Hi Zeke,

    I am afraid that we are unable to replicate the mentioned error.
    Therefore could you please send us your grid declaration? Thus I would be able to follow your scenario and setup and thus try finding a proper resolution for you.

    Looking forward your reply,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  16. Zeke Sheppard
    Zeke Sheppard avatar
    32 posts
    Member since:
    Oct 2009

    Posted 01 Feb 2010 Link to this post

    No need, I've moved back to the MS GridView control. Working with the Telerik control is not worth my time or your trouble to resolve this issue. Invariably, using any Telerik solution, it takes days to get something working properly that should (and does) take only a few minutes to implement using other tools.

    Please expand your QA department to catch (and resolve, hopefully?) at least a few of the defects that are shipped with your products.
  17. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 02 Feb 2010 Link to this post

    Hello Zeke,

    To help you in understanding how RadControls for ASP.NET AJAX work and can be used in custom applications detailed information is provided in our online help here. You can also refer to RadControls for ASP.NET AJAX demos to see them in action.

    However if these resources are not sufficient for you to resolve a particular issue, the best option is to let us know of the problems you are facing. For that purpose you can open a formal support ticket and send us a stripped version of your scenario in a runnable project. Thus we would be able do our best in providing a quick resolution for your case.

    Other than this, we could hardly determine the source of an issue without having enough information on the situations in which they appear.  
       
    All the best,
    Iana
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  18. Craig Kennedy
    Craig Kennedy avatar
    4 posts
    Member since:
    Jan 2010

    Posted 17 Feb 2010 Link to this post

    I'm having a very similar problem.  When I have a GridCalculatedColumn in my column collection and I group by a column, I get the error "An item with the same key has already been added".  When I remove the calculated column, I have no problems with the grouping.  Here is my grid definition.  I would appreciate any assistance you could offer.  Thanks in advance.
        <rad:RadGrid ID="RadGrid1" runat="server" AllowSorting="True" GridLines="Horizontal" 
            Skin="Windows7" BorderColor="Black" AutoGenerateColumns="False" ShowGroupPanel="True" ShowFooter="true"
            <MasterTableView > 
                <Columns> 
                    <rad:GridTemplateColumn HeaderText="Order/Line" SortExpression="Order_ID, Line_Number" 
                        ItemStyle-VerticalAlign="Top" ItemStyle-Wrap="false" Groupable="false"
                        <ItemTemplate> 
                            <%#Eval("Order_Id")%>/<%#Eval("Line_Number")%> 
                        </ItemTemplate> 
                        <ItemStyle VerticalAlign="Top" Wrap="False"></ItemStyle> 
                    </rad:GridTemplateColumn> 
                    <rad:GridBoundColumn HeaderText="Part" DataField="Samtec_Part_Master_Description" 
                        ItemStyle-VerticalAlign="Top" ItemStyle-Wrap="false"
                        <ItemStyle VerticalAlign="Top" Wrap="False"></ItemStyle> 
                    </rad:GridBoundColumn> 
                    <rad:GridBoundColumn HeaderText="Quantity" DataField="Quantity_Shipped" DataFormatString="{0:N0}" 
                        HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" ItemStyle-VerticalAlign="Top" 
                        ItemStyle-Wrap="false" Groupable="false"
                        <HeaderStyle HorizontalAlign="Right"></HeaderStyle> 
                        <ItemStyle HorizontalAlign="Right" VerticalAlign="Top" Wrap="False"></ItemStyle> 
                    </rad:GridBoundColumn> 
                    <rad:GridBoundColumn HeaderText="Price" DataField="Net_Price" DataFormatString="{0:N3}" 
                        HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" ItemStyle-VerticalAlign="Top" 
                        ItemStyle-Wrap="false" Groupable="false"
                        <HeaderStyle HorizontalAlign="Right"></HeaderStyle> 
                        <ItemStyle HorizontalAlign="Right" VerticalAlign="Top" Wrap="False"></ItemStyle> 
                    </rad:GridBoundColumn> 
                    <rad:GridCalculatedColumn Aggregate="Sum" HeaderText="Extended" FooterText="Total: " 
                        DataFields="Net_Price, Quantity_Shipped" Expression="{0}*{1}" DataFormatString="{0:N2}" 
                        DataType="System.Decimal" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" 
                        ItemStyle-VerticalAlign="Top" UniqueName="ExtendedPrice" /> 
                    <rad:GridBoundColumn HeaderText="Shipped" DataField="Date_History" DataFormatString="{0:MM/dd/yyyy}" 
                        ItemStyle-VerticalAlign="Top" ItemStyle-Wrap="false"
                        <ItemStyle VerticalAlign="Top" Wrap="False"></ItemStyle> 
                    </rad:GridBoundColumn> 
                    <rad:GridBoundColumn HeaderText="Attention" DataField="Ship_Attention" ItemStyle-VerticalAlign="Top" 
                        ItemStyle-Wrap="false"
                        <ItemStyle VerticalAlign="Top" Wrap="False"></ItemStyle> 
                    </rad:GridBoundColumn> 
                    <rad:GridBoundColumn HeaderText="Buyer" DataField="Buyer_Name" ItemStyle-VerticalAlign="Top" 
                        ItemStyle-Wrap="false"
                        <ItemStyle VerticalAlign="Top" Wrap="False"></ItemStyle> 
                    </rad:GridBoundColumn> 
                    <rad:GridTemplateColumn HeaderText="Customer" SortExpression="Customer_Name" ItemStyle-VerticalAlign="Top" 
                        ItemStyle-Wrap="false" Groupable="false"
                        <ItemTemplate> 
                            <%#Eval("Customer_Name")%> 
                            <br /> 
                            <%#Eval("Address_1")%> 
                            <br /> 
                            <%#Eval("FORMATTED_CITY_POSTAL_CODE")%> 
                            <br /> 
                            <%#Eval("Country_Desc")%> 
                        </ItemTemplate> 
                        <ItemStyle VerticalAlign="Top" Wrap="False"></ItemStyle> 
                    </rad:GridTemplateColumn> 
                    <rad:GridBoundColumn HeaderText="End Customer" DataField="End_Customer" ItemStyle-VerticalAlign="Top" 
                        ItemStyle-Wrap="false"
                        <ItemStyle VerticalAlign="Top" Wrap="False"></ItemStyle> 
                    </rad:GridBoundColumn> 
                </Columns> 
            </MasterTableView> 
            <GroupingSettings ShowUnGroupButton="true" CaseSensitive="false" /> 
            <ClientSettings AllowDragToGroup="True" AllowExpandCollapse="false" /> 
        </rad:RadGrid> 
  19. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 18 Feb 2010 Link to this post

    Hello Craig,

    I followed your scenario and prepared a sample project attached to this post.
    Please check it out and let me know if it works as desired and what differs in your case.

    Best wishes,
    Iana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  20. Craig Kennedy
    Craig Kennedy avatar
    4 posts
    Member since:
    Jan 2010

    Posted 18 Feb 2010 Link to this post

    Your project works for me.  One difference I can see is that you are using a SqlDataSource and I am binding to the grid from the code behind in the page_load event.  Here is a sample of how I am binding the data.

        Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load 
            If Not String.IsNullOrEmpty(Request.QueryString("LocationId")) Then 
                Dim dt As New DataTable() 
     
                Using cn As New SqlConnection(ConnectionSGN) 
                    cn.Open() 
     
                    Using da As New SqlDataAdapter("SELECT * FROM TABLE WHERE FIELD = CRITERIA", cn) 
                        da.Fill(dt) 
                    End Using 
                End Using 
     
                RadGrid1.DataSource = dt 
                RadGrid1.DataBind() 
            End If 
        End Sub 
     

  21. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 23 Feb 2010 Link to this post

    Hello Craig,

    Could you please try bind the grid through its NeedDataSource event as described here instead of using simple data-binding and see if the error persists?

    Sincerely yours,
    Iana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  22. Miguel
    Miguel avatar
    25 posts
    Member since:
    Dec 2010

    Posted 11 Jan 2011 Link to this post

    Hello Iana

    I have the same problem.

    I bind the grid through its NeedDataSource event and the exception persists. I have set EnableLinqExpressions to false because if I set it to true I get this new error: Unable to cast object of type 'DynamicClass1' to type 'OES.Entity.OES_GeneracionGas'
     'OES.Entity.OES_GeneracionGas' is a custom class.

    My grid looks like this:

    <telerik:RadGrid runat="server" ID="RgridGeneracionGas" AutoGenerateColumns="False"
           OnNeedDataSource="RgridGeneracionGas_NeedDataSource" OnUpdateCommand="RgridGeneracionGas_UpdateCommand"
           OnItemDataBound="RgridGeneracionGas_ItemDataBound" OnInsertCommand="RgridGeneracionGas_InsertCommand"
           OnItemCreated="RgridGeneracionGas_ItemCreated" OnPreRender="RgridGeneracionGas_PreRender"
           OnItemCommand="RgridGeneracionGas_ItemCommand" AllowSorting="True" HorizontalAlign="Center"
           GridLines="None" ShowFooter="true" EnableLinqExpressions="false" AllowMultiRowEdit="true">
           <MasterTableView DataKeyNames="EQUIPO" ShowFooter="true" EditMode="InPlace" CommandItemDisplay="Top">
               <Columns>
                   <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton" />
                   <%--                            <telerik:GridBoundColumn DataField="FECHA" HeaderText="Fecha" ReadOnly="TRUE" DataFormatString="{0:d}"
                                   Visible="true" />--%>
                   <telerik:GridTemplateColumn UniqueName="EQUIPO" HeaderText="Generador" AllowFiltering="False"
                       Reorderable="False" Visible="True" DataType="System.String" FooterText="Totales:">
                       <ItemTemplate>
                           <asp:Label ID="Label3" runat="server">
                                  <%# DataBinder.Eval(Container.DataItem, "EQUIPO")%>
                           </asp:Label>
                       </ItemTemplate>
                       <EditItemTemplate>
                           <telerik:RadComboBox DataTextField="EQUIPO" DataValueField="EQUIPO" EnableLoadOnDemand="false"
                               ID="RadCmbBx_Equipo" runat="server" Height="140px" Width="120px" MarkFirstMatch="True">
                           </telerik:RadComboBox>
                           <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="RadCmbBx_Equipo"
                               InitialValue="Select..." ErrorMessage="Debe Escoger un Generador" Visible="false" />
                       </EditItemTemplate>
                       <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                           Font-Underline="False" HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
                       <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                           Font-Underline="False" HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
                   </telerik:GridTemplateColumn>
                   <telerik:GridNumericColumn FooterText="Total : " Aggregate="Sum" DataField="HORASON"
                       UniqueName="HORASON" HeaderText="Horas ON" ReadOnly="false" AllowRounding="true"
                       DataFormatString="{0:N}" />
                   <telerik:GridNumericColumn FooterText="Total : " Aggregate="Sum" DataField="ACUM_ENERGIA_AYER"
                       UniqueName="ACUM_ENERGIA_AYER" HeaderText="Contador Energia Ayer (MWH-DIA)" ReadOnly="false"
                       HeaderStyle-Width="100px" AllowRounding="true" DataFormatString="{0:N}" />
                   <telerik:GridNumericColumn FooterText="Total : " Aggregate="Sum" DataField="ACUM_ENERGIA_HOY"
                       UniqueName="ACUM_ENERGIA_HOY" HeaderText="Contador Energia Hoy (MWH-DIA)" ReadOnly="false"
                       HeaderStyle-Width="100px" AllowRounding="true" DataFormatString="{0:N}" />
                   <telerik:GridNumericColumn FooterText="Total : " Aggregate="Sum" DataField="ENERGIA"
                       UniqueName="ENERGIA" HeaderText="Energia (MWH)" ReadOnly="false" AllowRounding="true"
                       DataFormatString="{0:N}" />
                   <telerik:GridNumericColumn FooterText="Total : " Aggregate="Sum" DataField="POTENCIA"
                       UniqueName="POTENCIA" HeaderText="Potencia (MW)" ReadOnly="false" AllowRounding="true"
                       DataFormatString="{0:N}" />
                   <telerik:GridCalculatedColumn HeaderText="Average (MW)" UniqueName="AVERAGE" DataType="System.Double"
                       DataFields="ENERGIA, HORASON" Expression="{0}/{1}" Aggregate="Sum" FooterText="Total : "
                       DataFormatString="{0:N3}" />
               </Columns>
               <CommandItemTemplate>
                   <asp:LinkButton runat="server" ID="EditAll" CommandName="EditAll"
                       <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Edit.gif" />Edit All
                   </asp:LinkButton>
                   <asp:LinkButton runat="server" ID="UpdateAll" CommandName="UpdateAll"
                       <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Update.gif" /> Update All
                   </asp:LinkButton>
                   <asp:LinkButton runat="server" ID="CancelAll" CommandName="CancelAll">
                       <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Cancel.gif" /> Cancel Editing
                   </asp:LinkButton>
               </CommandItemTemplate>
               <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                   Font-Underline="False" HorizontalAlign="Center" VerticalAlign="Middle" Wrap="True" />
               <ItemStyle HorizontalAlign="Center" />
               <AlternatingItemStyle HorizontalAlign="Center" />
               <FooterStyle HorizontalAlign="Center" Font-Bold="true" />
           </MasterTableView>
           <PagerStyle Mode="NextPrevAndNumeric" />
           <ClientSettings EnableRowHoverStyle="true" AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true">
               <Selecting AllowRowSelect="False" />
           </ClientSettings>
       </telerik:RadGrid>

    The exception is thrown when the EditAll command is fired:


     protected void RgridGeneracionGas_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        if

    (e.CommandName == "EditAll")
        {

            foreach (GridDataItem item in RgridGeneracionGas.MasterTableView.Items)
            {
                item.Edit = true;
                      }
                      RgridGeneracionGas.Rebind();
           }
    }

    I really appreciate all your help. It is very difficult to me to create a working project and send it because this code is part of a major Project.

    Regards!
    Miguel

  23. Miguel
    Miguel avatar
    25 posts
    Member since:
    Dec 2010

    Posted 13 Jan 2011 Link to this post

    Hi,

    Is there any way to solve this?

    Thanks@
    Miguel
  24. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 14 Jan 2011 Link to this post

    Hi BILLY,

    I reviewed your code but I could not find the reason for the error there. Can you share the rest of the page code-behind? If you are adding some controls dynamically, try commenting the code for that out. Also specify if the Page.Render event is overridden. Is the grid ajaxified and are you adding any settings dynamically? You can disable ajax and see if the problem persists. Also make sure you are using only one ajax control to ajaxify the page, not RadAjaxManager and RadAjaxPanel or ASP:UpdatePanel at the same time.

    Kind regards,
    Iana
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  25. Miguel
    Miguel avatar
    25 posts
    Member since:
    Dec 2010

    Posted 14 Jan 2011 Link to this post

    Hi lana,

    This is the entire aspx and code behind:

    <%@ Page Language="C#" MasterPageFile="~/Master Page/Principal.Master" AutoEventWireup="true"
        CodeBehind="GeneracionGas.aspx.cs" Inherits="OES.Web.UI.Manage.GeneracionGas"
        Title="Untitled Page" %>
      
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <asp:Content ID="Content_App" ContentPlaceHolderID="ContentPlaceHolder_AppContent"
        runat="server">
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
      
            <script type="text/javascript">
                    function rowDblClick(sender, eventArgs) 
                    {
                        sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
                    }
                      
                   var oldValue;
                   function Focus(sender, eventArgs)
                   {
                        oldValue = sender.get_value();
                   }
                      
                   function Blur (sender, eventArgs)
                   {
      
                       if ( sender.get_value() < 0)
                       {
                            radalert('El valor no puede ser negativo',200,100,'Alerta');
                            sender.set_value(oldValue);
                       }                                    
                   }
      
            </script>
      
        </telerik:RadCodeBlock>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Outlook">
        </telerik:RadWindowManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadDatePicker1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RgridGeneracionGas" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <table style="width: 100%;">
            <tr>
                <td>
                    <asp:Label ID="Label1" runat="server" CssClass="Label_Bold" Font-Size="Small" Text="Fecha Procesamiento  "></asp:Label>
                    <telerik:RadDatePicker ID="RadDatePicker1" runat="server" Width="140px" OnSelectedDateChanged="RadDatePicker1_SelectedDateChanged"
                        Skin="Web20" AutoPostBack="True" Culture="English (United States)">
                        <DateInput ID="DateInput1" runat="server" AutoPostBack="True">
                        </DateInput>
                        <Calendar ID="Calendar1" runat="server" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False"
                            ViewSelectorText="x" Skin="Web20">
                        </Calendar>
                        <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
                    </telerik:RadDatePicker>
                </td>
                <td>
                </td>
            </tr>
        </table>
        <br />
        <asp:Label ID="Label2" runat="server" CssClass="Label_Bold" Font-Size="Small" Text="Generacion a Gas"></asp:Label>
        <telerik:RadGrid runat="server" ID="RgridGeneracionGas" AutoGenerateColumns="False"
            OnNeedDataSource="RgridGeneracionGas_NeedDataSource" OnUpdateCommand="RgridGeneracionGas_UpdateCommand"
            OnItemDataBound="RgridGeneracionGas_ItemDataBound" OnInsertCommand="RgridGeneracionGas_InsertCommand"
            OnItemCreated="RgridGeneracionGas_ItemCreated" OnPreRender="RgridGeneracionGas_PreRender"
            OnItemCommand="RgridGeneracionGas_ItemCommand" AllowSorting="True" HorizontalAlign="Center"
            GridLines="None" ShowFooter="true" EnableLinqExpressions="false" AllowMultiRowEdit="true">
            <MasterTableView DataKeyNames="EQUIPO" ShowFooter="true" EditMode="InPlace" CommandItemDisplay="Top">
                <Columns>
                    <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton" />
                    <%--                            <telerik:GridBoundColumn DataField="FECHA" HeaderText="Fecha" ReadOnly="TRUE" DataFormatString="{0:d}"
                                    Visible="true" />--%>
                    <telerik:GridTemplateColumn UniqueName="EQUIPO" HeaderText="Generador" AllowFiltering="False"
                        Reorderable="False" Visible="True" DataType="System.String" FooterText="Totales:">
                        <ItemTemplate>
                            <asp:Label ID="Label3" runat="server">
                                   <%# DataBinder.Eval(Container.DataItem, "EQUIPO")%>
                            </asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox DataTextField="EQUIPO" DataValueField="EQUIPO" EnableLoadOnDemand="false"
                                ID="RadCmbBx_Equipo" runat="server" Height="140px" Width="120px" MarkFirstMatch="True">
                            </telerik:RadComboBox>
                            <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="RadCmbBx_Equipo"
                                InitialValue="Select..." ErrorMessage="Debe Escoger un Generador" Visible="false" />
                        </EditItemTemplate>
                        <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                            Font-Underline="False" HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
                        <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                            Font-Underline="False" HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
                    </telerik:GridTemplateColumn>
                    <telerik:GridNumericColumn FooterText="Total : " Aggregate="Sum" DataField="HORASON"
                        UniqueName="HORASON" HeaderText="Horas ON" ReadOnly="false" AllowRounding="true"
                        DataFormatString="{0:N}" />
                    <telerik:GridNumericColumn FooterText="Total : " Aggregate="Sum" DataField="ACUM_ENERGIA_AYER"
                        UniqueName="ACUM_ENERGIA_AYER" HeaderText="Contador Energia Ayer (MWH-DIA)" ReadOnly="false"
                        HeaderStyle-Width="100px" AllowRounding="true" DataFormatString="{0:N}" />
                    <telerik:GridNumericColumn FooterText="Total : " Aggregate="Sum" DataField="ACUM_ENERGIA_HOY"
                        UniqueName="ACUM_ENERGIA_HOY" HeaderText="Contador Energia Hoy (MWH-DIA)" ReadOnly="false"
                        HeaderStyle-Width="100px" AllowRounding="true" DataFormatString="{0:N}" />
                    <telerik:GridNumericColumn FooterText="Total : " Aggregate="Sum" DataField="ENERGIA"
                        UniqueName="ENERGIA" HeaderText="Energia (MWH)" ReadOnly="false" AllowRounding="true"
                        DataFormatString="{0:N}" />
                    <telerik:GridNumericColumn FooterText="Total : " Aggregate="Sum" DataField="POTENCIA"
                        UniqueName="POTENCIA" HeaderText="Potencia (MW)" ReadOnly="false" AllowRounding="true"
                        DataFormatString="{0:N}" />
                    <%--                <telerik:GridCalculatedColumn HeaderText="Average (MW)" UniqueName="AVERAGE" DataType="System.Double"
                        DataFields="ENERGIA, HORASON" Expression="{0}/{1}" Aggregate="Sum" FooterText="Total : "
                        DataFormatString="{0:N3}"  />--%>
                </Columns>
                <CommandItemTemplate>
                    <asp:LinkButton runat="server" ID="EditAll" CommandName="EditAll"
                        <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Edit.gif" />Edit All
                    </asp:LinkButton>
                    <asp:LinkButton runat="server" ID="UpdateAll" CommandName="UpdateAll"
                        <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Update.gif" /> Update All
                    </asp:LinkButton>
                    <asp:LinkButton runat="server" ID="CancelAll" CommandName="CancelAll">
                        <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Cancel.gif" /> Cancel Editing
                    </asp:LinkButton>
                </CommandItemTemplate>
                <%--            <EditFormSettings ColumnNumber="2" PopUpSettings-Width="40%" CaptionFormatString="Edit Datos de Generacion Gas"
                    InsertCaption="Nuevo Registro Generacion Gas" FormCaptionStyle-Font-Bold="true"
                    PopUpSettings-Modal="true">
                    <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                    <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                    <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" Width="100%" />
                    <FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2" Height="110px" Width="100%"
                        BackColor="White" />
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <EditColumn ButtonType="ImageButton" />
                    <FormTableButtonRowStyle HorizontalAlign="Left" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                </EditFormSettings>--%>
                <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                    Font-Underline="False" HorizontalAlign="Center" VerticalAlign="Middle" Wrap="True" />
                <ItemStyle HorizontalAlign="Center" />
                <AlternatingItemStyle HorizontalAlign="Center" />
                <FooterStyle HorizontalAlign="Center" Font-Bold="true" />
            </MasterTableView>
            <PagerStyle Mode="NextPrevAndNumeric" />
            <ClientSettings EnableRowHoverStyle="true" AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true">
                <Selecting AllowRowSelect="False" />
            </ClientSettings>
        </telerik:RadGrid>
        <br />
        <br />
        <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" HorizontalAlign="Center"
            CssClass="Loading" />
    </asp:Content>

    C#

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Collections;
    using Telerik.Web.UI.Calendar;
    using Telerik.Web.UI;
    using OES.Entity;
    using OES.Web.UI.OXYSecurityService;
      
    namespace OES.Web.UI.Manage
    {
        public partial class GeneracionGas : System.Web.UI.Page
        {
            protected string TypeFunction
            {
                get
                {
                    if (ViewState["TypeFunction"] != null)
                    {
                        return (ViewState["TypeFunction"].ToString());
                    }
                    else
                    {
                        return "";
                    }
                }
                set
                {
                    ViewState["TypeFunction"] = value;
                }
            }
      
      
            protected void Page_Load(object sender, EventArgs e)
            {
      
                if (!IsPostBack)
                {
                    try
                    {
                        RadDatePicker1.SelectedDate = DateTime.Now.Date;
                        RadDatePicker1.MaxDate = DateTime.Now.Date.AddDays(1);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
      
            protected void ShowAlert(string msg)
            {
                RadAjaxManager1.ResponseScripts.Add(@"radalert('<b> " + msg + "</b>',300,100, 'Alerta'); ");
            }
      
      
            #region Methods CRUD
      
      
            protected void RgridGeneracionGas_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
            {
                try
                {
                    LoadGeneracion();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
      
            }
      
            protected void RgridGeneracionGas_UpdateCommand(object source, GridCommandEventArgs e)
            {
                try
                {
                    GridEditableItem editedItem = e.Item as GridEditableItem;
                    GridEditManager editMan = editedItem.EditManager;
                    var editableItem = ((GridEditableItem)e.Item);
                    OES_GeneracionGas gen = new OES_GeneracionGas();
                    string idEquipo;
                    Hashtable values = new Hashtable();
                    editableItem.ExtractValues(values);
                    idEquipo = editableItem.GetDataKeyValue("EQUIPO").ToString();
      
                    gen.EQUIPO = idEquipo;
                    gen.FECHA = Convert.ToDateTime(RadDatePicker1.SelectedDate);
                    gen.HORASON = Convert.ToDouble(values["HORASON"]);
                    gen.ACUM_ENERGIA_AYER = Convert.ToDouble(values["ACUM_ENERGIA_AYER"]);
                    gen.ACUM_ENERGIA_HOY = Convert.ToDouble(values["ACUM_ENERGIA_HOY"]);
                    gen.ENERGIA = Convert.ToDouble(values["ENERGIA"]);
                    gen.POTENCIA = Convert.ToDouble(values["POTENCIA"]);
      
      
      
                    new OES.Business.GeneracionGas().Update(gen);
                    RgridGeneracionGas.Controls.Add(new LiteralControl(string.Format("<span style='color:green'>{0}</span>", "Record Updated")));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
      
            }
      
            protected void RgridGeneracionGas_InsertCommand(object source, GridCommandEventArgs e)
            {
                try
                {
                    var editableItem = ((GridEditableItem)e.Item);
      
                    OES_GeneracionGas gen = new OES_GeneracionGas();
      
                    GridEditableItem editedItem = e.Item as GridEditableItem;
                    GridDataItem current = e.Item as GridDataItem;
                    GridEditManager editMan = editedItem.EditManager;
      
                    Hashtable values = new Hashtable();
                    editableItem.ExtractValues(values);
                    //Cuando la clave del combo es texto
                    RadComboBox comboEquipo = editedItem.FindControl("RadCmbBx_Equipo") as RadComboBox;
                    gen.EQUIPO = comboEquipo.SelectedValue;
      
                    gen.FECHA = Convert.ToDateTime(RadDatePicker1.SelectedDate);
                    gen.HORASON = Convert.ToDouble(values["HORASON"]);
                    gen.ACUM_ENERGIA_AYER = Convert.ToDouble(values["ACUM_ENERGIA_AYER"]);
                    gen.ACUM_ENERGIA_HOY = Convert.ToDouble(values["ACUM_ENERGIA_HOY"]);
                    gen.ENERGIA = Convert.ToDouble(values["ENERGIA"]);
                    gen.POTENCIA = Convert.ToDouble(values["POTENCIA"]);
      
                    if (!new OES.Business.GeneracionGas().Get(Convert.ToDateTime(RadDatePicker1.SelectedDate), gen.EQUIPO))
                    {
                        new OES.Business.GeneracionGas().Insert(gen);
                        RgridGeneracionGas.Controls.Add(new LiteralControl(string.Format("<span style='color:green'>{0}</span>", "Record Created")));
                    }
      
                    else
                    {
                        e.Canceled = true;
                        ShowAlert("Ya existe un registro en esta fecha para este Generador, Por favor verifique.");
      
                        //RgridGeneracionGas.Controls.Add(new LiteralControl(string.Format("<span style='color:red'>{0}</span>", "Record Already Exists")));
                    }
      
                }
                catch (Exception ex)
                {
                    throw ex;
                }
      
            }
            #endregion
      
      
            #region Other Methods
      
      
            protected void LoadGeneracion()
            {
                try
                {
                    if (RadDatePicker1.SelectedDate != null)
                    {
                        RgridGeneracionGas.DataSource = new OES.Business.GeneracionGas().List(Convert.ToDateTime(RadDatePicker1.SelectedDate));
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
      
      
      
            protected void RadDatePicker1_SelectedDateChanged(object sender, SelectedDateChangedEventArgs e)
            {
                if (RadDatePicker1.SelectedDate != null)
                {
                    RgridGeneracionGas.Rebind();
                }
            }
      
      
      
            protected void RgridGeneracionGas_ItemCreated(object sender, GridItemEventArgs e)
            {
                try
                {
                    if (TypeFunction == "R")
                    {
      
                        RgridGeneracionGas.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None;
      
                        GridEditCommandColumn editColumn = (GridEditCommandColumn)RgridGeneracionGas.MasterTableView.GetColumn("EditCommandColumn");
                        editColumn.Visible = false;
      
                    }
      
                    if (e.Item is GridEditableItem && (e.Item.IsInEditMode))
                    {
                        GridEditableItem item = e.Item as GridEditableItem;
      
                        GridNumericColumnEditor editorAcumEnerHoy = (GridNumericColumnEditor)item.EditManager.GetColumnEditor("ACUM_ENERGIA_HOY");
                        TableCell cellAcumEnerHoy = (TableCell)editorAcumEnerHoy.NumericTextBox.Parent;
                        RequiredFieldValidator validAcumEnerHoy = new RequiredFieldValidator();
                        editorAcumEnerHoy.NumericTextBox.ID = "validAcumEnerHoy";
                        validAcumEnerHoy.ControlToValidate = editorAcumEnerHoy.NumericTextBox.ID;
                        validAcumEnerHoy.ErrorMessage = "*";
                        cellAcumEnerHoy.Controls.Add(validAcumEnerHoy);
      
                        editorAcumEnerHoy.NumericTextBox.ClientEvents.OnBlur = "Blur";
                        editorAcumEnerHoy.NumericTextBox.ClientEvents.OnFocus = "Focus";
      
                        editorAcumEnerHoy.NumericTextBox.NumberFormat.KeepNotRoundedValue = true;
                        editorAcumEnerHoy.NumericTextBox.NumberFormat.DecimalDigits = 2;
      
      
      
                        GridNumericColumnEditor editorHorasON = (GridNumericColumnEditor)item.EditManager.GetColumnEditor("HORASON");
                        TableCell cellHorasON = (TableCell)editorHorasON.NumericTextBox.Parent;
                        RequiredFieldValidator validHorasON = new RequiredFieldValidator();
                        editorHorasON.NumericTextBox.ID = "validHorasON";
                        validHorasON.ControlToValidate = editorHorasON.NumericTextBox.ID;
                        validHorasON.ErrorMessage = "*";
                        cellHorasON.Controls.Add(validHorasON);
      
                        editorHorasON.NumericTextBox.ClientEvents.OnBlur = "Blur";
                        editorHorasON.NumericTextBox.ClientEvents.OnFocus = "Focus";
      
                        editorHorasON.NumericTextBox.NumberFormat.KeepNotRoundedValue = true;
                        editorHorasON.NumericTextBox.NumberFormat.DecimalDigits = 2;
      
      
                        GridNumericColumnEditor editorEnergia = (GridNumericColumnEditor)item.EditManager.GetColumnEditor("ENERGIA");
                        TableCell cellEnergia = (TableCell)editorEnergia.NumericTextBox.Parent;
                        RequiredFieldValidator validEnergia = new RequiredFieldValidator();
                        editorEnergia.NumericTextBox.ID = "validEnergia";
                        validEnergia.ControlToValidate = editorEnergia.NumericTextBox.ID;
                        validEnergia.ErrorMessage = "*";
                        cellEnergia.Controls.Add(validEnergia);
      
                        editorEnergia.NumericTextBox.ClientEvents.OnBlur = "Blur";
                        editorEnergia.NumericTextBox.ClientEvents.OnFocus = "Focus";
      
      
                        // editorEnergia.NumericTextBox.NumberFormat.KeepNotRoundedValue = true;
                        editorEnergia.NumericTextBox.NumberFormat.DecimalDigits = 2;
                        editorEnergia.NumericTextBox.NumberFormat.AllowRounding = true;
      
      
                        GridNumericColumnEditor editorPotencia = (GridNumericColumnEditor)item.EditManager.GetColumnEditor("POTENCIA");
                        TableCell cellPotencia = (TableCell)editorPotencia.NumericTextBox.Parent;
                        RequiredFieldValidator validPotencia = new RequiredFieldValidator();
                        editorPotencia.NumericTextBox.ID = "validPotencia";
                        validPotencia.ControlToValidate = editorPotencia.NumericTextBox.ID;
                        validPotencia.ErrorMessage = "*";
                        cellPotencia.Controls.Add(validPotencia);
      
                        editorPotencia.NumericTextBox.ClientEvents.OnBlur = "Blur";
                        editorPotencia.NumericTextBox.ClientEvents.OnFocus = "Focus";
      
                        editorPotencia.NumericTextBox.NumberFormat.KeepNotRoundedValue = true;
                        editorPotencia.NumericTextBox.NumberFormat.DecimalDigits = 2;
      
      
                        //RequiredFieldValidator validEquipo = item.FindControl("RequiredFieldValidator1") as RequiredFieldValidator;
                        //validEquipo.Enabled = false;
      
                    }
      
      
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
      
      
            protected void RgridGeneracionGas_ItemDataBound(object sender, GridItemEventArgs e)
            {
                if (e.Item is GridEditableItem && (e.Item.IsInEditMode))
                {
                    GridEditableItem item = e.Item as GridEditableItem;
      
                    RadComboBox comboEquipo = item.FindControl("RadCmbBx_Equipo") as RadComboBox;
                    comboEquipo.DataSource = new OES.Business.Equipo().ListGenGas(); ;
                    comboEquipo.DataBind();
                    comboEquipo.Items.Insert(0, new RadComboBoxItem("Select..."));
      
                    GridNumericColumnEditor EditEnerActAyer = (GridNumericColumnEditor)item.EditManager.GetColumnEditor("ACUM_ENERGIA_AYER");
                    EditEnerActAyer.NumericTextBox.Enabled = false;
      
                    if ((e.Item as GridEditableItem).IsInEditMode && (e.Item as GridEditableItem).IsDataBound && e.Item.ItemIndex != -1)
                    {
                        comboEquipo.SelectedValue = ((OES_GeneracionGas)e.Item.DataItem).EQUIPO.ToString();
                        comboEquipo.Enabled = false;
                    }
      
                }
            }
      
      
            int rowindex = -1;
            protected void RgridGeneracionGas_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
            {
                if (e.CommandName == RadGrid.UpdateCommandName)
                {
                    GridEditableItem editItem = (GridEditableItem)e.Item;
                    rowindex = editItem.ItemIndex;
      
                    if (!Page.IsValid)
                    {
                        e.Canceled = true;
      
                    }
                }
      
                if (e.CommandName == RadGrid.PerformInsertCommandName)
                {
                    if (!Page.IsValid)
                    {
                        e.Canceled = true;
                        ShowAlert("Hay Campos que son requeridos (*)");
                    }
                }
      
                if (e.CommandName == "EditAll")
                {
                    foreach (GridDataItem item in RgridGeneracionGas.MasterTableView.Items)
                    {
                        item.Edit = true;
      
                    }
                    GridEditCommandColumn editColumn = (GridEditCommandColumn)RgridGeneracionGas.MasterTableView.GetColumn("EditCommandColumn");
                    editColumn.Visible = false;
      
                    RgridGeneracionGas.Rebind();
      
                }
      
                if (e.CommandName == "CancelAll")
                {
                    e.Canceled = false;
                    GridEditCommandColumn editColumn = (GridEditCommandColumn)RgridGeneracionGas.MasterTableView.GetColumn("EditCommandColumn");
                    editColumn.Visible = true;
      
                }
      
      
                if (e.CommandName == "UpdateAll")
                {
      
                    foreach (GridEditableItem editedItem in RgridGeneracionGas.EditItems)
                    {
      
                        OES_GeneracionGas gen = new OES_GeneracionGas();
                        string idEquipo;
                        Hashtable values = new Hashtable();
                        editedItem.ExtractValues(values);
                        idEquipo = editedItem.GetDataKeyValue("EQUIPO").ToString();
      
                        gen.EQUIPO = idEquipo;
                        gen.FECHA = Convert.ToDateTime(RadDatePicker1.SelectedDate);
                        gen.HORASON = Convert.ToDouble(values["HORASON"]);
                        gen.ACUM_ENERGIA_AYER = Convert.ToDouble(values["ACUM_ENERGIA_AYER"]);
                        gen.ACUM_ENERGIA_HOY = Convert.ToDouble(values["ACUM_ENERGIA_HOY"]);
                        gen.ENERGIA = Convert.ToDouble(values["ENERGIA"]);
                        gen.POTENCIA = Convert.ToDouble(values["POTENCIA"]);
      
                        new OES.Business.GeneracionGas().Update(gen);
                        //RgridGeneradorDatosConsumo.Controls.Add(new LiteralControl(string.Format("<span style='color:green'>{0}</span>", "Record Updated")));
      
                        editedItem.Edit = false;
                        GridEditCommandColumn editColumn = (GridEditCommandColumn)RgridGeneracionGas.MasterTableView.GetColumn("EditCommandColumn");
                        editColumn.Visible = true;
                    }
      
                    RgridGeneracionGas.Rebind();
                }
      
            }
      
            protected void RgridGeneracionGas_PreRender(object sender, EventArgs e)
            {
                //RgridGeneracionGas.MasterTableView.GetColumn("HORASON").EditFormHeaderTextFormat = "<span style=color:red>Horas ON</span>";
                //RgridGeneracionGas.MasterTableView.GetColumn("ACUM_ENERGIA_HOY").EditFormHeaderTextFormat = "<span style=color:red>Contador Energia Hoy (MWH-DIA)</span>";
                //RgridGeneracionGas.MasterTableView.GetColumn("ENERGIA").EditFormHeaderTextFormat = "<span  style=color:red>Energia (MWH)</span>";
                //RgridGeneracionGas.MasterTableView.GetColumn("POTENCIA").EditFormHeaderTextFormat = "<span style=color:red>Potencia (MW)</span>";
      
      
                if (rowindex > -1)
                {
                    GridDataItem item = (GridDataItem)RgridGeneracionGas.Items[rowindex];
                    item.Selected = true;
                    rowindex = -1;
                }
            }
      
            #endregion
      
        }
    }

    Thank you very much!

    Miguel

  26. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 17 Jan 2011 Link to this post

    Hi Miguel,

    Thank you for sharing the full page code. I reviewed it however was not able to find anything disturbing which might be causing the error in questions. Therefore I would ask you to open a formal support ticket and send a runnable version of the page there. I will forward it for further debugging so we can find from where exactly the error comes.

    Greetings,
    Iana
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  27. Kashif
    Kashif avatar
    2 posts
    Member since:
    Dec 2010

    Posted 03 Mar 2011 Link to this post

    Hi,

    I ran into this same error today, and spent nearly the whole day trying to debug this.  I hope Telerik makes errors more descriptive.

    I am programmatically creating GridBoundColumn and GridHyperLinkColumn depending on values retrieved from DB, assign data source and bind.  Upon DataBind, I would get the above mentioned error.  I checked all the columns name being returned when adding grid columns and all the columns from data table.  They matched.  No duplicate column names, no duplicate DataField assigned.  Looking a bit closely at the creation of the GridHyperLinkColumn, I realized that the string array set as GridHyperLinkColumn.DataNavigateUrlFields has duplicate values.{"case","case"}. (name of column returned in data table).  When I removed the duplicate, it started working.  Phew....

    Hope this helps.

    Thanks,
    Kashif
  28. Adam Heeg
    Adam Heeg avatar
    19 posts
    Member since:
    Jul 2012

    Posted 24 Aug 2012 Link to this post

    I am getting the same error with a gridcalculatedcolumn An item with the same key has already been added


    This error only happens when the G.C.C. is added to the grid.  Based on this thread we clearly need to find a cause and resolution to this issue.  Below is my code, which you'll see using databinding as a previous posted did.

    Thank you,
    Adam

    Binding:
    Public Property RFQList As List(Of CRM_RFQ_SearchResult) Implements IRFQ_Dashboard.RFQList
        Get
            Return Session("RFQList")
        End Get
        Set(value As System.Collections.Generic.List(Of CRM_RFQ_SearchResult))
            Session("RFQList") = value
            rgRFQs.DataSource = value
            rgRFQs.DataBind()
        End Set
    End Property
     
    Protected Sub rgRFQs_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rgRFQs.NeedDataSource
        rgRFQs.DataSource = RFQList
     
    End Sub




    Markup
    <telerik:RadGrid
                ID="rgRFQs"
                runat="server"
                AllowSorting="True"
                AutoGenerateColumns="False"
                GridLines="Horizontal"
                HorizontalAlign="Center"
                AllowFilteringByColumn="True" EnableLinqExpressions="false"
                EnableViewState="false"
                PageSize="500"
                AllowPaging="True"
                Width="100%"
                ClientSettings-Selecting-AllowRowSelect="true"
                ClientSettings-EnableRowHoverStyle="true"
                OnItemCommand="rgRFQs_ItemCommand"
                OnItemDataBound="rgRFQs_ItemDataBound"
                OnNeedDataSource="rgRFQs_NeedDataSource"
                Skin="ISOHay"
                EnableEmbeddedSkins="false"
                CellSpacing="0"
                DataMember="RFQList"
                ShowFooter="true"
                ShowGroupPanel="True">
                <MasterTableView
                    IsFilterItemExpanded="false"
                    ItemStyle-Wrap="true"
                    DataKeyNames="RFQID"
                    DataMember="RFQList"
                    AllowMultiColumnSorting="false"
                    GroupLoadMode="Client"
                    HeaderStyle-ForeColor="White"
                    HeaderStyle-Font-Bold="true"
                    PagerStyle-Mode="NextPrevNumericAndAdvanced">
                    <CommandItemSettings
                        ExportToPdfText="Export to PDF" />
                    <RowIndicatorColumn
                        FilterControlAltText="Filter RowIndicator column"
                        Visible="True">
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn
                        FilterControlAltText="Filter ExpandColumn column"
                        Visible="True">
                    </ExpandCollapseColumn>
                    <Columns>
                        <%-- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
                                                                    Customer Data COLUMNS
                                  ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| --%>
                        <%--
                                                                            RFQId     
                        --%>
                        <telerik:GridTemplateColumn
                            Display="true"
                            AllowFiltering="false"
                            Groupable="false"
                            HeaderText="RFQ Id"
                            Aggregate="Count"
                            DataField="RFQID"
                            UniqueName="RFQID">
                            <ItemTemplate>
                                <asp:HyperLink
                                    ID="hlrfq"
                                    ForeColor="Black"
                                    runat="server"
                                    Text='<%# DataBinder.Eval(Container.DataItem, "RFQID") %>'
                                    NavigateUrl='<%# string.Format("~/Utilities/GoToRFQ.aspx?RFQID={0}", DataBinder.Eval(Container.DataItem, "RFQID")) %>' />
                            </ItemTemplate>
                            <HeaderStyle
                                BackColor="#555555"
                                HorizontalAlign="Center"
                                VerticalAlign="Middle" />
                        </telerik:GridTemplateColumn>
                        <%--
                                                                            Strategic     
                        --%>
                        <telerik:GridTemplateColumn
                            SortExpression="Strategic"
                            DataType="System.Boolean"
                            DataField="Strategic"
                            UniqueName="Strategic"
                            Groupable="false"
                            HeaderText=" § "
                            HeaderTooltip="Strategic Buyer">
                            <ItemTemplate>
                                <asp:Image
                                    runat="server"
                                    ID="mgStrategic" />
                            </ItemTemplate>
                            <HeaderStyle
                                BackColor="#555555"
                                HorizontalAlign="Center"
                                VerticalAlign="Middle" />
                        </telerik:GridTemplateColumn>
                        <%--
                                                                             Buyer     
                        --%>
                        <telerik:GridTemplateColumn
                            DataField="Buyer"
                            AllowFiltering="true"
                            GroupByExpression="Buyer, count(Buyer) Items [RFQ's],  sum(RFQItems) RFQItems [RFQ Items], sum(Fedlog_ext) $est [Total $Est] Group By Buyer"
                            Groupable="true"
                            FilterListOptions="VaryByDataType"
                            HeaderText="Customer"
                            DataType="System.String"
                            ItemStyle-HorizontalAlign="Left"
                            SortExpression="Buyer"
                            UniqueName="Buyer">
                            <ItemTemplate>
                                <asp:HyperLink
                                    ID="hlBuyer"
                                    ForeColor="Black"
                                    runat="server"
                                    Text='<%# DataBinder.Eval(Container.DataItem, "Buyer") %>'
                                    NavigateUrl='<%# string.Format("User.aspx?UserID={0}", DataBinder.Eval(Container.DataItem, "BuyerID")) %>' />
                            </ItemTemplate>
                            <HeaderStyle
                                Font-Underline="true"
                                BackColor="#555555"
                                HorizontalAlign="Center" />
                        </telerik:GridTemplateColumn>
                        <%--
                                                                            BuyerOrg     
                        --%>
                        <telerik:GridTemplateColumn
                            AllowFiltering="true"
                            GroupByExpression="BuyerOrg, count(BuyerOrg) Items [RFQ's],  sum(RFQItems) RFQItems [RFQ Items], sum(Fedlog_ext) $est [Total $Est] Group By BuyerOrg"
                            FilterListOptions="VaryByDataType"
                            Groupable="true"
                            DataField="BuyerOrg"
                            DataType="System.String"
                            HeaderText="Organization"
                            ItemStyle-HorizontalAlign="Left"
                            SortExpression="BuyerOrg"
                            UniqueName="BuyerOrg">
                            <ItemTemplate>
                                <asp:HyperLink
                                    ID="hlBuyerOrg"
                                    ForeColor="Black"
                                    runat="server"
                                    Text='<%# DataBinder.Eval(Container.DataItem, "BuyerOrg") %>'
                                    NavigateUrl='<%# string.Format("~/Trader/RFQ_Organization_View.aspx?OrganizationID={0}", DataBinder.Eval(Container.DataItem, "OrganizationID")) %>' />
                            </ItemTemplate>
                            <HeaderStyle
                                BackColor="#555555"
                                Font-Underline="true"
                                HorizontalAlign="Center"
                                Wrap="False" />
                        </telerik:GridTemplateColumn>
                        <%--
                                                                             BuyerReference     
                        --%>
                        <telerik:GridBoundColumn
                            AllowFiltering="true"
                            FilterListOptions="VaryByDataType"
                            AllowSorting="true"
                            DataField="BuyerReference"
                            DataType="System.String"
                            Groupable="false"
                            HeaderText="Cust RFQ Ref"
                            ItemStyle-HorizontalAlign="Center"
                            SortExpression="BuyerReference"
                            UniqueName="BuyerReference">
                            <HeaderStyle
                                BackColor="#555555"
                                HorizontalAlign="Center"
                                Wrap="False" />
                        </telerik:GridBoundColumn>
                        <%--
                                                                            BuyerPurchasesValue  
                             
                            FooterAggregateFormatString="{0:C}"
          
                        --%>
                        <telerik:GridNumericColumn
                            NumericType="Currency"
                            AllowFiltering="true"
                            FilterListOptions="VaryByDataType"
                            AllowSorting="true"
                            DataField="BuyerPurchasesValue"
                            DataType="System.Decimal"
                            HeaderText="$SO"
                            ItemStyle-HorizontalAlign="Right"
                            Resizable="false"
                            Groupable="false"
                            UniqueName="BuyerPurchasesValue">
                            <HeaderStyle
                                BackColor="#555555"
                                HorizontalAlign="Center"
                                Wrap="true" />
                        </telerik:GridNumericColumn>
                        <%--
                                                                            Customer_CloseRatio
                        --%>
                        <telerik:GridBoundColumn
                            Aggregate="Avg"
                            AllowFiltering="true"
                            Groupable="false"
                            FilterListOptions="VaryByDataType"
                            AllowSorting="true"
                            DataField="Customer_CloseRatio"
                            DataType="System.Int32"
                            DataFormatString="{0:#%}"
                            HeaderText="C/R"
                            ItemStyle-HorizontalAlign="Center"
                            SortExpression="Customer_CloseRatio"
                            UniqueName="Customer_CloseRatio">
                            <HeaderStyle
                                BackColor="#555555"
                                HorizontalAlign="Center"
                                Wrap="True" />
                        </telerik:GridBoundColumn>
                        <%--
                                                                            SalesMarket 
                        --%>
                        <telerik:GridBoundColumn
                            AllowSorting="true"
                            GroupByExpression="SalesMarket, count(SalesMarket) Items [RFQ's], sum(RFQItems) RFQItems [RFQ Items], sum(Fedlog_ext) $est [Total $Est] Group By SalesMarket"
                            FilterListOptions="VaryByDataType"
                            AllowFiltering="true"
                            DataField="SalesMarket"
                            DataType="System.String"
                            Groupable="true"
                            HeaderText="Mrkt"
                            ItemStyle-HorizontalAlign="Center"
                            SortExpression="SalesMarket"
                            UniqueName="SalesMarket">
                            <HeaderStyle
                                BackColor="#555555"
                                Font-Underline="true"
                                HorizontalAlign="Center"
                                Wrap="False" />
                        </telerik:GridBoundColumn>
                        <%--
                                                                            Customer_UserType
                        --%>
                        <telerik:GridBoundColumn
                            AllowFiltering="true"
                            FilterListOptions="VaryByDataType"
                            AllowSorting="true"
                            Display="false"
                            Groupable="false"
                            DataField="Customer_UserType"
                            DataType="System.String"
                            HeaderText="Customer Type"
                            ItemStyle-HorizontalAlign="Center"
                            SortExpression="Customer_UserType"
                            UniqueName="Customer_UserType">
                            <HeaderStyle
                                BackColor="#555555"
                                HorizontalAlign="Center"
                                Wrap="True" />
                        </telerik:GridBoundColumn>
                        <%-- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
                                                                    RFQ ITEM COLUMNS
                                  ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| --%>
                        <%--
                                                                    RFQStatus   Status
                        --%>
                        <telerik:GridBoundColumn
                            AllowSorting="true"
                            GroupByExpression="RFQStatus, count(RFQStatus) Items [RFQ's], sum(RFQItems) RFQItems [RFQ Items], sum(Fedlog_ext) $est [Total $Est] Group By RFQStatus"
                            FilterListOptions="VaryByDataType"
                            AllowFiltering="true"
                            Groupable="true"
                            DataField="RFQStatus"
                            DataType="System.String"
                            HeaderText="Status"
                            ItemStyle-HorizontalAlign="Center"
                            SortExpression="RFQStatus"
                            Visible="true"
                            UniqueName="RFQStatus">
                            <HeaderStyle
                                BackColor="#87907D"
                                Font-Underline="true"
                                HorizontalAlign="Center"
                                Wrap="False" />
                        </telerik:GridBoundColumn>
                        <%--
                                                                  DateCreated  Created
                        --%>
                        <telerik:GridBoundColumn
                            AllowSorting="true"
                            AllowFiltering="true"
                            FilterListOptions="VaryByDataType"
                            DataField="DateCreated"
                            DataType="System.DateTime"
                            HeaderText="Created"
                            DataFormatString="{0:MM/dd/yy}"
                            Groupable="false"
                            ItemStyle-HorizontalAlign="Center"
                            SortExpression="DateCreated"
                            UniqueName="DateCreated">
                            <HeaderStyle
                                BackColor="#87907D"
                                HorizontalAlign="Center"
                                Wrap="False" />
                        </telerik:GridBoundColumn>
                        <%--
                                                                    QuoteDeadline Deadline
                        --%>
                        <telerik:GridBoundColumn
                            AllowSorting="true"
                            FilterListOptions="VaryByDataType"
                            Groupable="false"
                            AllowFiltering="true"
                            DataField="QuoteDeadline"
                            DataFormatString="{0:MM/dd/yy}"
                            DataType="System.DateTime"
                            HeaderText="Deadline"
                            ItemStyle-HorizontalAlign="Center"
                            SortExpression="QuoteDeadline"
                            UniqueName="QuoteDeadline">
                            <HeaderStyle
                                BackColor="#87907D"
                                HorizontalAlign="Center"
                                Wrap="False" />
                        </telerik:GridBoundColumn>
                        <%--
                                                                    LI RFQItems
                        --%>
                        <telerik:GridBoundColumn
                            AllowSorting="true"
                            Aggregate="Sum"
                            FilterListOptions="VaryByDataType"
                            Groupable="false"
                            AllowFiltering="true"
                            DataField="RFQItems"
                            HeaderText="LI"
                            DataType="System.Int32"
                            ItemStyle-HorizontalAlign="Center"
                            SortExpression="RFQItems"
                            UniqueName="RFQItems">
                            <HeaderStyle
                                BackColor="#87907D"
                                HorizontalAlign="Center"
                                Wrap="False" />
                        </telerik:GridBoundColumn>
                        <%--
                                                                    $Opp FEDLOG_Ext
                        --%>
                        <telerik:GridNumericColumn
                            FooterAggregateFormatString="{0:C}"
                            NumericType="Currency"
                            AllowSorting="true"
                            Aggregate="Sum"
                            FilterListOptions="VaryByDataType"
                            Groupable="false"
                            AllowFiltering="true"
                            DataField="FEDLOG_Ext"
                            DataType="System.Decimal"
                            HeaderText="$Opp"
                            ItemStyle-HorizontalAlign="Right"
                            SortExpression="FEDLOG_Ext"
                            UniqueName="FEDLOG_Ext">
                            <HeaderStyle
                                BackColor="#87907D"
                                HorizontalAlign="Center"
                                Wrap="False" />
                        </telerik:GridNumericColumn>
                        <%-- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
                                                                    RFQ STATUS COLUMNS
                                  ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| --%>
                        <%--
                                                                    SR Items_SourcingRequested
                        --%>
                        <telerik:GridBoundColumn
                            AllowSorting="true"
                            Aggregate="Sum"
                            FilterListOptions="VaryByDataType"
                            AllowFiltering="true"
                            Groupable="false"
                            DataField="Items_SourcingRequested"
                            DataType="System.Int32"
                            ItemStyle-HorizontalAlign="Center"
                            HeaderText="SR"
                            UniqueName="Items_SourcingRequested">
                            <HeaderStyle
                                BackColor="#AAB6A2"
                                HorizontalAlign="Center"
                                Wrap="False" />
                        </telerik:GridBoundColumn>
                        <%--
                                                                    SC Items_SourcingCompleted
                        --%>
                        <telerik:GridBoundColumn
                            AllowSorting="true"
                            Aggregate="Sum"
                            FilterListOptions="VaryByDataType"
                            Groupable="false"
                            AllowFiltering="true"
                            DataField="Items_SourcingCompleted"
                            DataType="System.Int32"
                            HeaderText="SC"
                            ItemStyle-HorizontalAlign="Center"
                            UniqueName="Items_SourcingCompleted">
                            <HeaderStyle
                                BackColor="#AAB6A2"
                                HorizontalAlign="Center"
                                Wrap="False" />
                        </telerik:GridBoundColumn>
                        <%--
                                                                    SR - SC Incomplete SR
                        --%>
                        <telerik:GridCalculatedColumn
                            HeaderText="SR - SC"
                            UniqueName="IncompleteSR"
                            AllowSorting="true"
                            SortExpression="IncompleteSR"
                            Aggregate="Sum"
                            FilterListOptions="VaryByDataType"
                            Groupable="false"
                            AllowFiltering="true"
                            DataType="System.Int32"
                            DataFields="Items_SourcingRequested, Items_SourcingCompleted"
                            Expression="{0}-{1}">
                            <HeaderStyle
                                BackColor="#AAB6A2"
                                HorizontalAlign="Center"
                                Wrap="False" />
                            </telerik:GridCalculatedColumn>
                        <%--
                                                                    $S PricedSuppliers_EstCost
                         
                        <telerik:GridBoundColumn
                            AllowSorting="true"
                            Aggregate="Sum"
                            AllowFiltering="true"
                            FilterListOptions="VaryByDataType"
                            DataField="PricedSuppliers_EstCost"
                            DataFormatString="{0:$###,###.##}"
                            DataType="System.Decimal"
                            HeaderText="$S"
                            ItemStyle-HorizontalAlign="Center"
                            UniqueName="PricedSuppliers_EstCost">
                            <HeaderStyle
                                BackColor="#AAB6A2"
                                HorizontalAlign="Center"
                                Wrap="False" />
                            <ItemStyle
                                HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>--%>
                        <%--
                                                                    Q RFQ_ItemsQuoted
                        --%>
                        <telerik:GridBoundColumn
                            AllowSorting="true"
                            Aggregate="Sum"
                            FilterListOptions="VaryByDataType"
                            Groupable="false"
                            AllowFiltering="true"
                            DataField="RFQ_ItemsQuoted"
                            DataType="System.Int32"
                            HeaderText="Q"
                            ItemStyle-HorizontalAlign="Center"
                            SortExpression="RFQ_ItemsQuoted"
                            UniqueName="RFQ_ItemsQuoted">
                            <HeaderStyle
                                BackColor="#AAB6A2"
                                HorizontalAlign="Center"
                                Wrap="False" />
                        </telerik:GridBoundColumn>
                        <%--
                                                                    $Q RFQ_QuotedValue
                        --%>
                        <telerik:GridNumericColumn
                            FooterAggregateFormatString="{0:C}"
                            NumericType="Currency"
                            AllowSorting="true"
                            Aggregate="Sum"
                            FilterListOptions="VaryByDataType"
                            Groupable="false"
                            AllowFiltering="true"
                            DataField="RFQ_QuotedValue"
                            DataType="System.Decimal"
                            HeaderText="$Q"
                            ItemStyle-HorizontalAlign="Right"
                            SortExpression="RFQ_QuotedValue"
                            UniqueName="RFQ_QuotedValue">
                            <HeaderStyle
                                BackColor="#AAB6A2"
                                HorizontalAlign="Center"
                                Wrap="False" />
                        </telerik:GridNumericColumn>
                        <%--
                                                                            Trader     
                        --%>
                        <telerik:GridBoundColumn
                            AllowFiltering="true"
                            GroupByExpression="Trader, count(Trader) Items [RFQ's],  sum(RFQItems) RFQItems [RFQ Items], sum(Fedlog_ext) $est [Total $Est] Group By Trader"
                            FilterListOptions="VaryByDataType"
                            AllowSorting="true"
                            Groupable="true"
                            DataField="Trader"
                            DataType="System.String"
                            HeaderText="Employee"
                            ItemStyle-HorizontalAlign="Center"
                            SortExpression="Trader"
                            UniqueName="Trader">
                            <HeaderStyle
                                BackColor="#AAB6A2"
                                Font-Underline="true"
                                HorizontalAlign="Center"
                                Wrap="False" />
                        </telerik:GridBoundColumn>
                    </Columns>
                    <EditFormSettings>
                        <EditColumn
                            FilterControlAltText="Filter EditCommandColumn column">
                        </EditColumn>
                    </EditFormSettings>
                    <ItemStyle
                        Wrap="True" />
                    <PagerStyle
                        Mode="NextPrevNumericAndAdvanced" />
                    <HeaderStyle
                        BackColor="#4086AA"
                        Font-Bold="True"
                        ForeColor="White" />
                </MasterTableView>
                <ClientSettings
                    EnablePostBackOnRowClick="False"
                    AllowColumnsReorder="True"
                    AllowDragToGroup="True"
                    AllowGroupExpandCollapse="true"
                    ReorderColumnsOnClient="True">
                    <ClientEvents />
                    <Selecting
                        AllowRowSelect="True" />
                </ClientSettings>
                <GroupingSettings
                    CaseSensitive="false"
                    ShowUnGroupButton="true" />
            </telerik:RadGrid>
  29. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 28 Aug 2012 Link to this post

    Hello Adam,

    I have created a sample RadGrid web site using the provided code. On my side everything works as expected and the grid gets loaded correctly. Please check out the attached application and try to distinguish the crucial differences between our projects.

    Furthermore, I have noticed that in the provided code sample that you are using Simple DataBinding( DataBind() ). Please note that you should not call DataBind() method when you are Advanced ( NeedDataSource ) or Declarative DataBinding, as noted in the following topic:
    http://www.telerik.com/help/aspnet-ajax/grid-advanced-data-binding.html

    I hope this will prove helpful.

    Greetings,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017