Column Does not belong to table DefaultView

22 posts, 0 answers
  1. Brett
    Brett avatar
    40 posts
    Member since:
    Mar 2008

    Posted 12 Mar 2012 Link to this post

    I have a RadGrid that i'm putting into default edit mode following the documentation here: http://www.telerik.com/help/aspnet/grid/grddefaulteditmodeforgriditemsoninitialload.html

    Everything works great, except when I have a GridHyperlinkColumn. I will get the error: Column 'FileName' does not belong to table DefaultView.
    My HyerlinkColumn code looks like this:
    <telerik:GridHyperLinkColumn HeaderText="View Hyperlink" DataTextFormatString="View Hyperlink"
                       DataNavigateUrlFields="FileName" UniqueName="FileName2" DataNavigateUrlFormatString="http://www.xyz.com/{0}"
                       ShowFilterIcon="false" DataTextField="FileName" AllowFiltering="false" >
                   </telerik:GridHyperLinkColumn>


    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            foreach (GridItem item in RadGrid1.MasterTableView.Items)
            {
                if (item is GridEditableItem)
                {
                    GridEditableItem editableItem = item as GridDataItem;
                    editableItem.Edit = true;
                }
            }
            RadGrid1.Rebind(); // It fails with the error here, when the Grid is rebinding.
        }

    The error will fail when the grid is rebinding. I'm assuming it's trying to put the HylinkColumn into edit mode, but I don't know enough about the RadGrid to tell it to skip it in the foreach loop.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Mar 2012 Link to this post

    Hello,

    Try setting the Edit property of all grid rows to true on initial load hooking the ItemCreated event as follows.
    C#:
    void radgrid1_ItemCreated(object sender, GridItemEventArgs e)
     {
      if (!Page.IsPostBack && e.Item is GridEditableItem)
       {
        e.Item.Edit = true;
       }
     }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brett
    Brett avatar
    40 posts
    Member since:
    Mar 2008

    Posted 13 Mar 2012 Link to this post

    I have the following below and is still doesn't work. :(

    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            LinkButton lnkBtnDelete = (LinkButton)item["AutoGeneratedDeleteColumn"].Controls[0];
            lnkBtnDelete.Attributes["onclick"] = "javascript:return confirm(\'Do you want to delete this item?\')";
        }
        if (!Page.IsPostBack && e.Item is GridEditableItem)
        {
            e.Item.Edit = true;
        }
  5. Eric Villemure
    Eric Villemure avatar
    19 posts
    Member since:
    Feb 2008

    Posted 13 Mar 2012 Link to this post

    We have the same problem here but are unable to reproduce in a separate project.

    It all started when we integrated version 2012 Q1.

    We have tried todays internal build : 2012.1.313

    If you find something let us know.
  6. Yunuen Sanchez
    Yunuen Sanchez avatar
    31 posts
    Member since:
    Aug 2009

    Posted 13 Mar 2012 Link to this post

    Same problem here. Everything was working fine after I updated to 2012.1.215.40.

    UPDATE:
    In my case, that only happens with GridHyperLinkColumn; I use a GridTemplateColumn with an asp:Hyperlink instead, and everything went back to normal.
  7. Christopher Lee
    Christopher Lee avatar
    22 posts
    Member since:
    Mar 2006

    Posted 20 Mar 2012 Link to this post

    I'm having the exact same problem. Very frustrating.  It's happening each time I click on the pager at the bottom of the page, even though I'm not placing anything into edit mode.
  8. Christopher Lee
    Christopher Lee avatar
    22 posts
    Member since:
    Mar 2006

    Posted 20 Mar 2012 Link to this post

    Your workaround works.  Thank you!
  9. Anne
    Anne avatar
    39 posts
    Member since:
    May 2010

    Posted 20 Apr 2012 Link to this post

    Hello,

    I have the same problem with 2012.1411.35

    I will change the type of my column, in wait.
  10. Daniel
    Daniel avatar
    17 posts
    Member since:
    Nov 2004

    Posted 20 Apr 2012 Link to this post

    We are experiencing the same problem with 2012.1.411.40. This is new with the 2012 release. The stack trace for the exception looks like this -

    [ArgumentException: Column 'X' does not belong to table Table.]
       System.Data.DataRow.get_Item(DataColumn column, DataRowVersion version) +6312665
       Telerik.Web.UI.GridHyperLinkColumn.OnDataBindColumn(Object sender, EventArgs e) +147
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +304
       System.Web.UI.Control.DataBindChildren() +11426631
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +321
       System.Web.UI.Control.DataBindChildren() +11426631
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +321
       Telerik.Web.UI.GridItem.SetupItem(Boolean dataBind, Object dataItem, GridColumn[] columns, ControlCollection rows) +895
       Telerik.Web.UI.GridItemBuilder.InitializeItem(Int32 dataSourceIndex, String& nextItemHierarchicalIndex, Boolean& itemIsInEditMode) +236
       Telerik.Web.UI.GridItemBuilder.CreateItems(GridGroupingContext group) +453
       Telerik.Web.UI.GridTableView.CreateItems(IEnumerator enumerator, GridColumn[] columns, ControlCollection controls) +161
       Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +1466
       Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +874
       System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +94
       System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +182
       Telerik.Web.UI.GridTableView.PerformSelect() +216
       Telerik.Web.UI.GridTableView.DataBind() +441
       Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) +2489
       Telerik.Web.UI.RadGrid.OnLoad(EventArgs e) +294
       System.Web.UI.Control.LoadRecursive() +71
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064
  11. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 25 Apr 2012 Link to this post

    Hello,

    I tried to reproduce the described issue but to no avail. I am sending you a simple example, please check it out and let me know what differs in your case.

    Looking forward for your reply.

    Kind regards,
    Radoslav
    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.
  12. Adam
    Adam avatar
    3 posts
    Member since:
    Oct 2010

    Posted 07 May 2012 Link to this post

    We are seeing the same issue after on GridHyperLinkCoumns after updating to 2012.215.40.
    I found where we were databinding the grid twice (manually setting datasource and calling DataBind() method... second binding probably was an oversight) on postbacks.
    If I removed one of the calls, the error stopped. Not sure the cause but hoping it may help someone else.
  13. Jon
    Jon avatar
    2 posts
    Member since:
    Nov 2011

    Posted 23 Jul 2012 Link to this post

    Thanks Adam.  Your observation helped a lot.

    In my case I had code handling the Init event for my grid:
    If Not IsPostBack Then
      Dim colDates As GridBoundColumn
      colDates = Me.rgAssetsBase.Columns.FindByUniqueName("CountedDate")
      colDates.DataFormatString = "{0:MM/dd/yy}"
      Me.rgAssetsBase.Rebind()
    End If

    When removed the Rebind() line I was able to load my page again.  This was with 2012.1.411.40.

    As it happens, I was able to get rid of the entire code block once I realized the DataFormatString could be modified at design time. 

    Telerik:  have you tested RadGridHyperlinkColumn with Rebind or Databind?
  14. Griffin
    Griffin avatar
    5 posts
    Member since:
    Jul 2009

    Posted 16 Oct 2012 Link to this post

    I encountered the issue described in this thread and contacted support.  After I provided an example demonstrating the behavior it's been identified as a bug.  You can follow issue ID 12960 in PITS.
  15. Christopher Lee
    Christopher Lee avatar
    22 posts
    Member since:
    Mar 2006

    Posted 23 Oct 2012 Link to this post

    When will this problem be fixed?
  16. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 26 Oct 2012 Link to this post

    Hi Christopher,

    The described issue is already fixed from our developers and the fix will be available into the hotfix dll in the end of the next week. On the following link you could find instructions how to use the hotfix dlls:
    http://www.telerik.com/help/aspnet-ajax/introduction-using-hotfix.htmlI

    Kind regards,
    Radoslav
    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.
  17. Christopher Lee
    Christopher Lee avatar
    22 posts
    Member since:
    Mar 2006

    Posted 26 Oct 2012 Link to this post

    Hi Radoslav,

    That is great news! Thank you for letting me know. I will check back toward the end of next week to examine the hotfix.

    All the best,

    Chris
  18. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 07 Nov 2012 Link to this post

    This is still an issue for me when I use a gridhyperlinkcolumn:
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript" language="javascript">
     
            function getQuerystring(key, default_) {
                if (default_ == null) default_ = "";
                key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
                var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
                var qs = regex.exec(window.location.href);
                if (qs == null)
                    return default_;
                else
                    return qs[1];
            }
            function AddTaskModal() {
     
                var param1 = getQuerystring('IDProcedures');
     
                var oWnd = radopen("Procedures_task_modal.aspx?IDProcedures=" + param1, "UserListDialog");
     
                return false;
            }
            function refreshGrid(arg) {
                if (!arg) {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                }
                else {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
                }
            }
     
        </script>
    </telerik:RadCodeBlock>

    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="sds_Tasks" GridLines="None"
        Skin="WebBlue">
        <MasterTableView AutoGenerateColumns="False" DataSourceID="sds_Tasks">
            <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
            <RowIndicatorColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn DataField="EnterDate" DataType="System.DateTime" HeaderText="Enter Date"
                    SortExpression="EnterDate" UniqueName="EnterDate" DataFormatString="{0:MM/dd/yyyy}"
                    ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center">
                    <ItemStyle Width="100px"></ItemStyle>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Subject" HeaderText="Subject" SortExpression="Subject"
                    UniqueName="Subject">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ResolutionDeadline" DataType="System.DateTime"
                    HeaderText="Task Deadline" SortExpression="ResolutionDeadline" UniqueName="ResolutionDeadline"
                    DataFormatString="{0:MM/dd/yyyy}" ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center">
                    <ItemStyle Width="100px"></ItemStyle>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ResolutionDate" DataType="System.DateTime" HeaderText="Resolution Date"
                    SortExpression="ResolutionDate" UniqueName="ResolutionDate" DataFormatString="{0:MM/dd/yyyy}"
                    ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center">
                    <ItemStyle Width="100px"></ItemStyle>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="FullName" HeaderText="Technician" ReadOnly="True"
                    SortExpression="FullName" UniqueName="FullName" ItemStyle-Width="125px">
                    <ItemStyle Width="100px"></ItemStyle>
                </telerik:GridBoundColumn>
                <telerik:GridHyperLinkColumn DataNavigateUrlFields="IDTasks" DataNavigateUrlFormatString="tasks_details.aspx?IDTasks={0}"
                    Text="Details" UniqueName="IDTasks" AllowFiltering="False">
                    <ItemStyle Width="50px" CssClass="radgrid" />
                </telerik:GridHyperLinkColumn>
            </Columns>
            <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                Font-Underline="False" HorizontalAlign="Center" Wrap="True" />
        </MasterTableView>
    </telerik:RadGrid>

    <asp:SqlDataSource ID="sds_Tasks" runat="server" ConnectionString="<%$ ConnectionStrings:IT_CentralConnectionString %>"
        SelectCommand="SELECT [IDTasks], [EnterDate], [ResolutionDeadline], [ResolutionDate], [FullName], [Subject] FROM [vw_ITC_Tasks] WHERE ([IDProcedures] = @IDProcedures)">
        <SelectParameters>
            <asp:QueryStringParameter Name="IDProcedures" QueryStringField="IDProcedures" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
     
        Dim RadGrid1 As RadGrid = DirectCast(FindControl("RadGrid1"), RadGrid)
     
        If e.Argument = "Rebind" Then
            RadGrid1.MasterTableView.SortExpressions.Clear()
            RadGrid1.MasterTableView.GroupByExpressions.Clear()
            RadGrid1.Rebind()
     
        ElseIf e.Argument = "RebindAndNavigate" Then
            RadGrid1.MasterTableView.SortExpressions.Clear()
            RadGrid1.MasterTableView.GroupByExpressions.Clear()
            RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1
            RadGrid1.Rebind()
        End If
     
    End Sub



    I downloaded the HotFix DLL:

    2012.3.1016.40 and copied it to my BIN folde

    I use the radgridhyperlinkcolum ALOT and would hat to have to go back and change them all to gridtemplates with an ASP Hyperlink

    Any help much appreciated.

    Allan Browning





  19. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 12 Nov 2012 Link to this post

    Hi Allan,

    From the provided code snippets I saw that you are attach handler to the RadAjaxManager1.AjaxRequest twice:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
      
        Dim RadGrid1 As RadGrid = DirectCast(FindControl("RadGrid1"), RadGrid)
      
        If e.Argument = "Rebind" Then
            RadGrid1.MasterTableView.SortExpressions.Clear()
            RadGrid1.MasterTableView.GroupByExpressions.Clear()
            RadGrid1.Rebind()
      
        ElseIf e.Argument = "RebindAndNavigate" Then
            RadGrid1.MasterTableView.SortExpressions.Clear()
            RadGrid1.MasterTableView.GroupByExpressions.Clear()
            RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1
            RadGrid1.Rebind()
        End If
      
    End Sub

    Could you please try attaching handler to the RadAjaxManager1.AjaxRequest event only once and let me know if the issue still persist:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
      
        Dim RadGrid1 As RadGrid = DirectCast(FindControl("RadGrid1"), RadGrid)
      
        If e.Argument = "Rebind" Then
            RadGrid1.MasterTableView.SortExpressions.Clear()
            RadGrid1.MasterTableView.GroupByExpressions.Clear()
            RadGrid1.Rebind()
      
        ElseIf e.Argument = "RebindAndNavigate" Then
            RadGrid1.MasterTableView.SortExpressions.Clear()
            RadGrid1.MasterTableView.GroupByExpressions.Clear()
            RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1
            RadGrid1.Rebind()
        End If
      
    End Sub

    Looking forward for your reply.

    Regards,
    Radoslav
    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.
  20. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 13 Nov 2012 Link to this post

    Still does.

    Updated RadAjaxManager:

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                        <telerik:AjaxSetting AjaxControlID="RadGrid1">
                            <UpdatedControls>
                                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                            </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
    </telerik:RadAjaxManager>



    Here is the error from the debugger:

    Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bAjaxControlToolkit%2c+Version%3d4.1.40412.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d28f01b0e84b6d53e%3aen-US%3aacfc7575-cdee-46af-964f-5d85d9cdcf92%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2012.3.1016.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3aeedc0a8d-48b8-46b8-a699-de66b4bdef1e%3a16e4e7cd%3af7645509%3a24ee1bba%3af46195d3%3a1e771326%3a4cacbc31%3a58366029%3a86526ba7%3a19620875%3a874f8ea2%3a490a9d4e%3abd8f85e4%3aed16cbdc, line 9 character 15443

  21. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 16 Nov 2012 Link to this post

    Hello Allan,

    I tried to reproduce the problem but to no avail. I am sending you a simple example based on your code, please check it out and let me know what differs in your case.

    Looking forward for your reply.

    All the best,
    Radoslav
    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.
  22. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 16 Nov 2012 Link to this post

    Radoslav,

    I am embarrased to say but I see what I must have done. When you asked me to remove this portion form my Ajax manager:

    OnAjaxRequest="RadAjaxManager1_AjaxRequest"

    I thought I did so and I must have copied my code and pasted here BEFORE I actually saved the page.

    When I looked at my code today, I saw that that paramater was still there. When I removed it and resaved the page, the issue was resolved.

    I appologize for making you spend time on this when it was clearly my mistake.

    I sincerely appreciate your time.

    Thank you.

  23. Alan
    Alan avatar
    1 posts
    Member since:
    Sep 2011

    Posted 02 Dec 2012 Link to this post

    FYI, the hotfix worked in my code as well. I don't see it specifically mentioned in the version notes.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017