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

Column 'xyz' does not belong to table DefaultView.

7 Answers 271 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sunil
Top achievements
Rank 1
Sunil asked on 02 Jun 2011, 05:00 PM
Hi all,

I have a RadGrid with has a custom template for inserting records. Once I insert the record, I try to close the insert template with the following code:

else if (e.CommandName == RadGrid.PerformInsertCommandName)
            {
                e.Canceled = true;
                e.Item.OwnerTableView.InsertItem();
 
                RadGrid_Visitor_RT.MasterTableView.IsItemInserted = false;
                RadGrid_Visitor_RT.Rebind();
 
            }

Calling the Rebind() method throws the following error:

Column 'Function_Key_Description' does not belong to table DefaultView.

The code for the RadGrid is below.

<telerik:RadGrid ID="RadGrid_Visitor_RT" runat="server" AutoGenerateColumns="false" Width="100%"
            AllowMultiRowSelection="false" AllowPaging="True" AllowCustomPaging="False" PageSize="10" AllowAutomaticInserts="False"
            GridLines="None" CellPadding="0" AllowSorting="false" Skin="Outlook" OnItemDataBound="Visitor_RT_ItemDataBound"
            ItemStyle-VerticalAlign="Top" OnNeedDataSource="RadGrid_Visitor_RT_NeedDataSource"
            OnItemCommand="RadGrid_Visitor_RT_ItemCommand">
 
                <PagerStyle Mode="NextPrevAndNumeric"/>
 
                <MasterTableView Width="100%" CommandItemDisplay="Top" GridLines="None" AllowAutomaticInserts="True">
 
                <CommandItemSettings ShowAddNewRecordButton="true" AddNewRecordText="Create Transaction" ShowRefreshButton="false" ShowExportToCsvButton="false"
                 ShowExportToExcelButton="false" ShowExportToPdfButton="false" ShowExportToWordButton="false"/>
                    <Columns>
                         
                         <telerik:GridBoundColumn UniqueName="User_Logs_Auto_ID" DataField="User_Logs_Auto_ID"
                         HeaderText="Log ID" Visible="false"/>
 
                         <telerik:GridBoundColumn UniqueName="User_Logs_DateTime" DataField="User_Logs_DateTime"
                         HeaderText="Time" HeaderStyle-Width="35%" Visible="true" ItemStyle-VerticalAlign="Top" />
 
                        <telerik:GridImageColumn DataType="System.String" AlternateText="F_Key"
                        DataAlternateTextField="Function_Key_Description" UniqueName="GridImageColumn_Function_Key"
                        ImageAlign="Middle" ImageHeight="16px" ImageWidth="23px" HeaderText=""
                        DataImageUrlFields="Function_Key_Description"
                        DataImageUrlFormatString="Images/OnTime_Fkeys/{0}.png" HeaderStyle-Width="10%"/>
 
                        <telerik:GridBoundColumn UniqueName="Terminal_Name" DataField="Terminal_Name"
                         HeaderText="Terminal Name" HeaderStyle-Width="25%" Visible="true" ItemStyle-VerticalAlign="Top"/>
 
                         <telerik:GridBoundColumn UniqueName="Terminal_Location" DataField="Terminal_Location"
                         HeaderText="Terminal Location" HeaderStyle-Width="30%" Visible="true" ItemStyle-VerticalAlign="Top"/>
 
 
                    </Columns>

Can anyone tell me why the Rebind method is throwing this error on the GridImageColumn?

Thanks,

Sunny

7 Answers, 1 is accepted

Sort by
0
Sunil
Top achievements
Rank 1
answered on 04 Jun 2011, 01:47 PM
Anyone?? :)
0
Tsvetina
Telerik team
answered on 07 Jun 2011, 11:34 AM
Hello Sunil,

The InsertItem() method is used when you perform automatic updates. Since you are binding your grid programmatically, item insertion should be performed manually, similarly to the following help article and demo:
Inserting values using UserControl/FormTemplate
Form Template Edit Form

All the best,
Tsvetina
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.

0
Sunil
Top achievements
Rank 1
answered on 07 Jun 2011, 12:11 PM
Thanks for the reply.

I've looked at the code in that explanation.

You're have instructed that InsertItem() can't be used.... So how do I close the FormTemplate once and item is inserted? Remove the insertItem() leaves me with this code:

if (e.CommandName == RadGrid.PerformInsertCommandName)
            {
                e.Item.OwnerTableView.GetInsertItem();
                GridEditableItem editedItem = e.Item as GridEditableItem;

                 
                //Code to close insert template
                RadGrid_Visitor_RT.MasterTableView.IsItemInserted = false;
                e.Item.OwnerTableView.Rebind();
 
            }


The line " RadGrid_Visitor_RT.MasterTableView.IsItemInserted = false; " throws the error:

Sys.WebForms.PageRequestManagerServerErrorException: Insert item is available only when grid is in insert mode.

How do I close the FormTemplate Grid?

Thanks,

Sunny
0
Tsvetina
Telerik team
answered on 07 Jun 2011, 12:37 PM
Hello Sunil,

Your code does not actually perform any insert action - with manual operations, you need to construct an appropriate object and insert it inside the grid datasource.

Also, you do not need to cancel the insert command in order to insert an item unless you want to perform some customizations before performing the insert. You do not also need to explicitly rebind the grid afterwards. If you perform a regular insert, the insert item will close by itself.

All the best,
Tsvetina
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.

0
Sunil
Top achievements
Rank 1
answered on 07 Jun 2011, 01:07 PM
Hi,

Thank you for your reply once again.

I do know the code posted here does not insert any item. I have removed code for simplicity. All the (manual) missing code did was connect to a db insert the data (which it did correctly).

My issue is when it has inserted the data, it doesn't close the FormTemplate.

I'm not sure I'm understanding what you say in the second paragraph.... I've inserted the Item in the database, I don't want to make it appear in the RadGrid... "If you perform a regular insert, the insert item will close by itself." ??

Sorry to be a pain!

Sunny
0
Tsvetina
Telerik team
answered on 07 Jun 2011, 01:49 PM
Hi Sunil,

What I mean is that when your insert goes without interrupting the grid event sequence, you do not need to explicitly set any properties or rebind the grid in order for the insert form to close. Therefore, I suggest you to try without the following lines:

e.Canceled = true;
  
....
  
RadGrid_Visitor_RT.MasterTableView.IsItemInserted = false;
RadGrid_Visitor_RT.Rebind();

If this does not help, try temporarily turning AJAX off in order to see if and where server exceptions are thrown.

Greetings,
Tsvetina
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.

0
Sunil
Top achievements
Rank 1
answered on 07 Jun 2011, 02:02 PM
Hi,

I removed those lines as requested and it doesn't throw any errors but it still doesn't close the FormTemplate either....

I found out what the problem was though.

In my RadGrid Tag I had AllowAutomaticInserts="False." However, in my MasterTableView I had this property set to True. Setting it to False has now closed the FormTemplate.

Thank you so much for your help and patience!

Sunny
Tags
Grid
Asked by
Sunil
Top achievements
Rank 1
Answers by
Sunil
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or