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?
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" />
{
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" />