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

RadGrid: Edit mode

4 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Siva
Top achievements
Rank 1
Siva asked on 31 Oct 2012, 09:47 AM
I have a radgrid with more than 35 columns(headers). I want to edit a record(edit mode=popup) it encounter the following error. "Sys.WebForms.PageRequestManagerServerErrorException: Editor cannot be initialized for column: 36".
Please help..

4 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 01 Nov 2012, 05:58 PM
Hello Siva,

Based on the information provided it is hard to say what is causing this behaviour at your end. Could you please post you aspx code with the related code behind, so we could give you a more straight forward solution?

Kind regards,
Angel Petrov
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.
0
Siva
Top achievements
Rank 1
answered on 02 Nov 2012, 05:33 AM
Thanks for rpy
 Here is my aspx code:

 <div>
        <telerik:RadGrid AutoGenerateColumns="false" ID="rgControl" Width="100%" AllowFilteringByColumn="True"
            AllowSorting="True" PageSize="15" ShowFooter="True" AllowPaging="True" runat="server"
            GridLines="None" OnNeedDataSource="rgControl_NeedDataSource" OnItemCommand="rgControl_ItemCommand"
            CellSpacing="0" EnableEmbeddedSkins="false" CssClass="RadGridCustomClass" OnColumnCreated="rgControl_ColumnCreated"
            Height="520px" AutoGenerateEditColumn="true" OnItemDataBound="rgControl_ItemDataBound"  OnPreRender="rgControl_PreRender">
            <ClientSettings Resizing-AllowColumnResize="true">
                <Selecting AllowRowSelect="true" />
                <Scrolling AllowScroll="true" ScrollHeight="400px" UseStaticHeaders="true" />
            </ClientSettings>
            <GroupingSettings CaseSensitive="false" />
            <MasterTableView AutoGenerateColumns="true" EditMode="PopUp" AllowFilteringByColumn="True"
                ShowFooter="True" TableLayout="Auto" AllowAutomaticUpdates="true">
                <EditFormSettings CaptionFormatString="Add/Edit Mode" PopUpSettings-ScrollBars="Auto">
                    <PopUpSettings Height="300" Width="900" Modal="true" ShowCaptionInEditForm="false" />
                </EditFormSettings>
                <Columns>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </div>


My Code Behind:

  protected void Page_Load(object sender, EventArgs e)
        {


        }
        protected void rgControl_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            try
            {
                rgControl.DataSource = GetDataTable("Select * from abc");// abc table having more than 35 columns
                rgControl.Rebind();
            }
            catch (Exception ex)
            {
            }
        }

        #region "   ITEM DATA BOUND                                 "
        protected void rgControl_ItemDataBound(object sender, GridItemEventArgs e)
        {
            try
            {
                if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                {
                    GridEditableItem item = (GridEditableItem)e.Item;
                    foreach (GridColumn gc in rgControl.MasterTableView.AutoGeneratedColumns)
                    {
 TextBox txt = (TextBox)item[gc].Controls[0];
                        if (txt != null)
                            txt.Width = Unit.Pixel(160);// I want 160 px width for each text box 
                    }
                }
            }
            catch (Exception ex)
            {
                
            }
        }
        #endregion

        #region "   PRE RENDER                                      "
        protected void rgControl_PreRender(object sender, EventArgs e)
        {
// I need 7 text boxes for column. So I am setting  EditFormColumnIndex 
            try
            {
                int j = 0, k = 1;
                foreach (GridColumn gc in rgControl.MasterTableView.AutoGeneratedColumns)
                {
                    if (j < k * 7)
                    {
                        gc.EditFormColumnIndex = k - 1;
                    }
                    else
                    {
                        k++;
                        gc.EditFormColumnIndex = k - 1;
                    }
                    j++;
                } ///  I think here is the mistake(for edited items) 

            }
            catch (Exception ex)
            {
            }
        }
        #endregion

In prerender method i am setting edit from index( i am not initialized any editor item from code behind.). when i remove the above code(logic) it working good. can u suggest me to set editcolumnindex(in popup). or any other solution ?.. 
"Error: "  Sys.WebForms.PageRequestManagerServerErrorException: Editor cannot be initialized for column:5 . 
0
Angel Petrov
Telerik team
answered on 06 Nov 2012, 05:35 PM
Hi Siva,

I examined your code carefully and there are some issues that need to be cleared.
  1. EditFormColumnIndex works only when EditMode is set to EditForms and EditFormSettings-ColumnsCount is set to a number larger than 1. This property specifies in which column of the edit form the edit field for this column will reside.
  2. Also you should not call Rebind() or DataBind() method in the NeedDataSource (please review the following help article).
I have created a simple project demonstrating the correct way how to use EditFormColumnIndex using your code(you can find it in the attachments). I also suggest that you take a look at this demo(implementing a similar scenario) and this help article in which you can find more about column types and their properties.

Regards,
Angel Petrov
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.
0
Siva
Top achievements
Rank 1
answered on 07 Nov 2012, 05:53 AM
Thank you very much for your answer.


By setting Columnnumber in editform my problem was solved.
<EditFormSettings ColumnNumber="15" />
Tags
Grid
Asked by
Siva
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Siva
Top achievements
Rank 1
Share this question
or