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

Problem with Databinding on insert

2 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 14 Oct 2010, 04:47 PM
I am using Telerik for the first time with SQL Server instead of Oracle. I am coding this in C#

I use the following code:

<asp:TextBox id="txtAgencyName" runat="server"
            Text='<%# DataBinder.Eval( Container, "DataItem.[Agency Name]"  ) %>' Width="268px" 
            ></asp:TextBox>

When I perform an edit eveything is fine but when I try and perform an isert I get the following error:

DataBinding: 'Telerik.Web.UI.GridInsertionObject' does not allow indexed access.

There are a few fields in front of this code that work fine. Why is this happening? Do I need to write a code aroubnf for this?

Here is the table breakdown.

USE [CommissionsEngine]
GO
/****** Object:  Table [dbo].[Agencies]    Script Date: 10/14/2010 11:46:11 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Agencies](
    [AgencyID] [varchar](4) NOT NULL,
    [AgencyName] [varchar](255) NULL,
    [EffDate] [datetime] NULL,
    [ExpireDate] [datetime] NULL,
    [Retention] [money] NULL CONSTRAINT [DF_Agencies_Retention]  DEFAULT ((0)),
    [FMO_OverrideID] [varchar](4) NULL,
    [FMO_OverrideAmount] [money] NULL CONSTRAINT [DF_Agencies_FMO_OverrideAmount]  DEFAULT ((0)),
    [DirectorID] [int] NULL,
    [ND_Director_Override] [money] NULL CONSTRAINT [DF_Agencies_ND_Director_Override]  DEFAULT ((0)),
    [IsFMO] [varchar](1) NULL,
    [DateEntered] [datetime] NULL CONSTRAINT [DF_Agencies_DateEntered]  DEFAULT (getdate()),
    [EnteredBy] [varchar](50) NULL CONSTRAINT [DF_Agencies_EnteredBy]  DEFAULT (suser_sname()),
 CONSTRAINT [PK_Agencies] PRIMARY KEY CLUSTERED 
(
    [AgencyID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 70) ON [PRIMARY]
) ON [PRIMARY]
  
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[Agencies]  WITH CHECK ADD  CONSTRAINT [FK_Agencies_Directors] FOREIGN KEY([DirectorID])
REFERENCES [dbo].[Directors] ([DirectorID])
GO
ALTER TABLE [dbo].[Agencies] CHECK CONSTRAINT [FK_Agencies_Directors]

2 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 14 Oct 2010, 06:31 PM
I have found what appears to be a bug in Telerik. he problem is in the brackets "[]" when issuing an edit command the brackets work as they should allowing you to have apces in your data name. However, this fails when issuing an insert commend to the grid. During the insert function this should always return a null value or zero length string. It should not be even trying to determne a value.

The work around is not to use aliases with spaces in them. I hope Telerik can address this issue as this is a pretty serious bug to me but one that could be easily resolved by looking at the state of the grid.

I am using the demo mode of the product while waiting for the company I am consulting at to purchase some licenses for the developers. Can somebody tell me how to report this bug properly to Telerik?
0
Radoslav
Telerik team
answered on 20 Oct 2010, 09:56 AM
Hi David,

The described behavior is expected. When the RadGrid goes to InitInsert mode the GridInsertionObject is created and all fields are bound to the GridInsertionObject's properties. These properties are created based on the column names. However in your case the column name contains the square brackets "[]" and the C#  parser understand the property in brackets as an indexer. To avoid the described error you could try renaming the column, or using a 'select as' statement into the select query.

Greetings,
Radoslav
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
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or