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

Auto Generated Data Columns Resulting in Blank Edit Form

2 Answers 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 24 Aug 2012, 03:49 PM
Hello,

I am working with a Rad Grid which is bound to an sql datasource in asp.net. It is displaying data from user defined tables so I need to generate alot of the grid at runtime with c# and work with auto generated columns. My problem is that I can't get the edit form to show any controls what so ever. I'm new to telerik controls so there might be something obvious I'm missing. 

I'm gathering from the examples on this site that to setup an edit form control for each column I just create a GridTextBoxColumnEditor 
as below and then in c# set the columns 'ColumnEditorID' to the ID of the GridTextBoxColumnEditor. Firstly, am I correct in thinking this is the way to map a grid column to a control in the edit form? The relevant code is below along with the way I've setup my datasource and radgrid. What am I missing?


protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
    {
        if (e.Column is GridBoundColumn)
        {
            (e.Column as GridBoundColumn).ColumnEditorID = "GridTextBoxColumnEditor1";
        }
    } 

<asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          DataSourceMode="DataReader"
          ConnectionString="Server=(local); Database=v7; uid=Vestri; pwd=v3str199!;"
          DeleteCommand='<%=SqlDeleteQuery %>'>
        </asp:SqlDataSource>
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="true" AllowAutomaticUpdates="true" OnItemDeleted="RadGrid1_ItemDeleted" 
        DataSourceID="SqlDataSource1" AutoGenerateColumns="true" OnColumnCreated="RadGrid1_ColumnCreated">
            <MasterTableView>
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="editButton" />
                    </telerik:GridEditCommandColumn>
                    <telerik:GridButtonColumn ConfirmText="Delete this record?" ConfirmDialogType="RadWindow"
                            ConfirmTitle="Delete" CommandName="Delete" Text="Delete"
                            UniqueName="DeleteColumn" ButtonType="ImageButton">
                            <ItemStyle HorizontalAlign="Center" CssClass="deleteImage" />
                    </telerik:GridButtonColumn>                 
                </Columns>
                <EditFormSettings ColumnNumber="3" CaptionDataField="Town" CaptionFormatString="Edit properties of {0}"
                    InsertCaption="New Town">
                    <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                    <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                    <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
                    Width="100%" />
                    <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record"
                    UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                </EditColumn>
                <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
            </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>
        <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="200px" />

2 Answers, 1 is accepted

Sort by
0
Steven
Top achievements
Rank 1
answered on 25 Aug 2012, 08:26 AM
I debugged this problem and it seems as though none of the auto generated columns are being recognised so I can't assign them. I've tried generated the columns in code behind but that just adds two new null columns every time the page posts back and there doesn't seem to be alot I can do to stop that happening. 
0
Andrey
Telerik team
answered on 29 Aug 2012, 10:26 AM
Hello,

When you are using AutoGeneratedColumns column editors are also automatically generated for the created columns, so you do not need to create manually column editors.

However, if you want to modify the look and feel of the autogenerated column editors you could use the approach described in this and this help topic.

Additionally, you could check this online demo application for a sample how ColumnEditors could be used.

All the best,
Andrey
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.
Tags
Grid
Asked by
Steven
Top achievements
Rank 1
Answers by
Steven
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or