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

RadGrid inside form template of other RadGrid bot displaying

1 Answer 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mohammed
Top achievements
Rank 1
Mohammed asked on 23 Dec 2013, 07:45 AM
<telerik:RadGrid ID="RadGrid" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
                AllowFilteringByColumn="True" AllowSorting="True" AutoGenerateColumns="False" CellSpacing="0" DataSourceID="SqlDataSource"
                EnableEmbeddedSkins="False" GridLines="None" PageSize="5" ShowStatusBar="True">
                <MasterTableView DataKeyNames="ID" DataSourceID="SqlDataSource" AutoGenerateColumns="false" AllowPaging="true" PageSize="10" CommandItemDisplay="Top">
                    <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Add New Company" RefreshText="Refresh" />
                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                        <HeaderStyle Width="20px" />
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                        <HeaderStyle Width="20px" />
                    </ExpandCollapseColumn>
                    <Columns>
                        <telerik:GridTemplateColumn HeaderText="No." AllowFiltering="false">
                            <ItemTemplate>
                                <asp:Label ID="IDLabel" runat="server" Text=""></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="40px" />
                            <ItemStyle HorizontalAlign="Center" Width="40px" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="CompanyName" FilterControlAltText="Filter CompanyName column" FilterControlWidth="100%" HeaderText="Name" SortExpression="CompanyName"
                            AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" UniqueName="CompanyName">
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="CompanyCommercialRegistrationNo" FilterControlAltText="Filter CompanyCommercialRegistrationNo column" FilterControlWidth="100%" HeaderText="Registration No" SortExpression="CompanyCommercialRegistrationNo"
                            AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" UniqueName="CompanyCommercialRegistrationNo">
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="CompanyOfficePhoneNumber" FilterControlAltText="Filter CompanyOfficePhoneNumber column" FilterControlWidth="100%" HeaderText="Office Number" SortExpression="CompanyOfficePhoneNumber"
                            AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" UniqueName="CompanyOfficePhoneNumber">
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="CompanyFaxNumber" FilterControlAltText="Filter CompanyFaxNumber column" FilterControlWidth="100%" HeaderText="Fax Number" SortExpression="CompanyFaxNumber"
                            AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" UniqueName="CompanyFaxNumber">
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="CompanyEmail" FilterControlAltText="Filter CompanyEmail column" FilterControlWidth="100%" HeaderText="Email ID" SortExpression="CompanyEmail"
                            AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" UniqueName="CompanyEmail">
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="AddedBy" FilterControlAltText="Filter AddedBy column" FilterControlWidth="100%" HeaderText="AddedBy" SortExpression="Added By"
                            AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" UniqueName="AddedBy">
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ID" Visible="false" DataType="System.Int64" FilterControlWidth="100%" FilterControlAltText="Filter ID column" HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="CompanySite" Visible="false" FilterControlWidth="100%" FilterControlAltText="Filter CompanySite column" HeaderText="Company Site" ReadOnly="True" SortExpression="CompanySite" UniqueName="CompanySite">
                        </telerik:GridBoundColumn>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderText="Edit" UniqueName="EditCommand" EditImageUrl="../../Design/MeStyle/Grid/Edit.gif" />
                    </Columns>
                    <EditFormSettings EditFormType="Template">
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column" />
                        <FormTemplate>
                            <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                    <div class="art-layout-cell layout-item-4" style="width: 30%;">
                                        <asp:Label ID="label_CompanyName" AssociatedControlID="txt_CompanyName" runat="server" Text="Company Name:" />
                                    </div>
                                    <div class="art-layout-cell layout-item-4" style="width: 60%;">
                                        <telerik:RadTextBox ID="txt_CompanyName" runat="server" InvalidStyleDuration="100" SelectionOnFocus="SelectAll" Width="80%" Text='<%#Bind("CompanyName")%>'>
                                            <HoveredStyle Font-Bold="True" ForeColor="#FF3300" />
                                            <EnabledStyle BackColor="Azure" PaddingRight="10px" />
                                        </telerik:RadTextBox>
                                        <asp:RequiredFieldValidator ID="CompanyNameRequired" runat="server" ControlToValidate="txt_CompanyName" ErrorMessage="*" ForeColor="Red" />
                                    </div>
                                </div>
                                <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                    <div class="art-layout-cell layout-item-4" style="width: 30%;">
                                        <asp:Label ID="label_CompanyCommercialRegistrationNo" AssociatedControlID="txt_CompanyCommercialRegistrationNo" runat="server" Text="Company Commercial Registration No:" />
                                    </div>
                                    <div class="art-layout-cell layout-item-4" style="width: 60%;">
                                        <telerik:RadTextBox ID="txt_CompanyCommercialRegistrationNo" runat="server" InvalidStyleDuration="100" SelectionOnFocus="SelectAll" Width="80%" Text='<%#Bind("CompanyCommercialRegistrationNo")%>'>
                                            <HoveredStyle Font-Bold="True" ForeColor="#FF3300" />
                                            <EnabledStyle BackColor="Azure" PaddingRight="10px" />
                                        </telerik:RadTextBox>
                                        <asp:RequiredFieldValidator ID="CompanyCommercialRegistrationNoRequired" runat="server" ControlToValidate="txt_CompanyCommercialRegistrationNo" ErrorMessage="*" ForeColor="Red" />
                                    </div>
                                </div>
                                <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                    <div class="art-layout-cell layout-item-4" style="width: 30%;">
                                        <asp:Label ID="label_CompanyType" AssociatedControlID="txt_CompanyType" runat="server" Text="Company Type:" />
                                    </div>
                                    <div class="art-layout-cell layout-item-4" style="width: 60%;">
                                        <telerik:RadTextBox ID="txt_CompanyType" runat="server" InvalidStyleDuration="100" SelectionOnFocus="SelectAll" Width="80%" Text='<%#Bind("CompanyType")%>'>
                                            <HoveredStyle Font-Bold="True" ForeColor="#FF3300" />
                                            <EnabledStyle BackColor="Azure" PaddingRight="10px" />
                                        </telerik:RadTextBox>
                                        <asp:RequiredFieldValidator ID="CompanyTypeRequired" runat="server" ControlToValidate="txt_CompanyType" ErrorMessage="*" ForeColor="Red" />
                                    </div>
                                </div>
                                <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                    <div class="art-layout-cell layout-item-4" style="width: 30%;">
                                        <asp:Label ID="label_CompanyCreationDate" AssociatedControlID="txt_CompanyCreationDate" runat="server" Text="Company Creation Date:" />
                                    </div>
                                    <div class="art-layout-cell layout-item-4" style="width: 60%;">
                                        <telerik:RadDatePicker ID="txt_CompanyCreationDate" runat="server" Width="80%" DbSelectedDate='<%#Bind("CompanyCreationDate")%>'>
                                            <DateInput ID="DateInput" runat="server" Font-Size="Medium" DateFormat="dd/MM/yyyy" DisplayDateFormat="dd/MM/yyyy">
                                                <HoveredStyle Font-Bold="True" ForeColor="#FF3300" />
                                                <EnabledStyle BackColor="Azure" PaddingRight="10px" />
                                            </DateInput>
                                        </telerik:RadDatePicker>
                                        <asp:RequiredFieldValidator ID="CompanyCreationDateRequired" runat="server" ControlToValidate="txt_CompanyCreationDate" ErrorMessage="*" ForeColor="Red" />
                                    </div>
                                </div>
                                <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                    <div class="art-layout-cell layout-item-4" style="width: 30%;">
                                        <asp:Label ID="label_CompanyDegree" AssociatedControlID="txt_CompanyDegree" runat="server" Text="Company Degree:" />
                                    </div>
                                    <div class="art-layout-cell layout-item-4" style="width: 60%;">
                                        <telerik:RadTextBox ID="txt_CompanyDegree" runat="server" InvalidStyleDuration="100" SelectionOnFocus="SelectAll" Width="80%" Text='<%#Bind("CompanyDegree")%>'>
                                            <HoveredStyle Font-Bold="True" ForeColor="#FF3300" />
                                            <EnabledStyle BackColor="Azure" PaddingRight="10px" />
                                        </telerik:RadTextBox>
                                        <asp:RequiredFieldValidator ID="CompanyDegreeRequired" runat="server" ControlToValidate="txt_CompanyDegree" ErrorMessage="*" ForeColor="Red" />
                                    </div>
                                </div>
                                <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                    <div class="art-layout-cell layout-item-4" style="width: 30%;">
                                        <asp:Label ID="label_CompanySite" AssociatedControlID="txt_CompanySite" runat="server" Text="Company Site:" />
                                    </div>
                                    <div class="art-layout-cell layout-item-4" style="width: 60%;">
                                        <telerik:RadTextBox ID="txt_CompanySite" runat="server" InvalidStyleDuration="100" SelectionOnFocus="SelectAll" Width="80%" Text='<%#Bind("CompanySite")%>'>
                                            <HoveredStyle Font-Bold="True" ForeColor="#FF3300" />
                                            <EnabledStyle BackColor="Azure" PaddingRight="10px" />
                                        </telerik:RadTextBox>
                                        <asp:RequiredFieldValidator ID="CompanySiteRequired" runat="server" ControlToValidate="txt_CompanySite" ErrorMessage="*" ForeColor="Red" />
                                    </div>
                                </div>
                                <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                    <div class="art-layout-cell layout-item-4" style="width: 30%;">
                                        <asp:Label ID="label_CompanyDescription" AssociatedControlID="txt_CompanyDescription" runat="server" Text="Company Description:"></asp:Label>
                                    </div>
                                    <div class="art-layout-cell layout-item-4" style="width: 60%; height: 80px;">
                                        <telerik:RadTextBox ID="txt_CompanyDescription" runat="server" Height="80px" InvalidStyleDuration="100" TextMode="MultiLine" Width="80%" Text='<%# Bind("CompanyDescription")%>'>
                                            <HoveredStyle Font-Bold="True" ForeColor="#FF3300" />
                                            <EnabledStyle BackColor="Azure" PaddingRight="10px" />
                                        </telerik:RadTextBox>
                                    </div>
                                </div>
                                <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                    <div class="art-layout-cell layout-item-4" style="width: 30%;">
                                        <asp:Label ID="label_CompanyOfficePhoneNumber" AssociatedControlID="txt_CompanyOfficePhoneNumber" runat="server" Text="Office Phone Number:" />
                                    </div>
                                    <div class="art-layout-cell layout-item-4" style="width: 60%;">
                                        <telerik:RadTextBox ID="txt_CompanyOfficePhoneNumber" runat="server" InvalidStyleDuration="100" SelectionOnFocus="SelectAll" Width="80%" Text='<%#Bind("CompanyOfficePhoneNumber")%>'>
                                            <HoveredStyle Font-Bold="True" ForeColor="#FF3300" />
                                            <EnabledStyle BackColor="Azure" PaddingRight="10px" />
                                        </telerik:RadTextBox>
                                        <asp:RequiredFieldValidator ID="CompanyOfficePhoneNumberRequired" runat="server" ControlToValidate="txt_CompanyOfficePhoneNumber" ErrorMessage="*" ForeColor="Red" />
                                    </div>
                                </div>
                                <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                    <div class="art-layout-cell layout-item-4" style="width: 30%;">
                                        <asp:Label ID="label_CompanyFaxNumber" AssociatedControlID="txt_CompanyFaxNumber" runat="server" Text="Fax Number:" />
                                    </div>
                                    <div class="art-layout-cell layout-item-4" style="width: 60%;">
                                        <telerik:RadTextBox ID="txt_CompanyFaxNumber" runat="server" InvalidStyleDuration="100" SelectionOnFocus="SelectAll" Width="80%" Text='<%#Bind("CompanyFaxNumber")%>'>
                                            <HoveredStyle Font-Bold="True" ForeColor="#FF3300" />
                                            <EnabledStyle BackColor="Azure" PaddingRight="10px" />
                                        </telerik:RadTextBox>
                                        <asp:RequiredFieldValidator ID="CompanyFaxNumberRequired" runat="server" ControlToValidate="txt_CompanyFaxNumber" ErrorMessage="*" ForeColor="Red" />
                                    </div>
                                </div>
                                <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                    <div class="art-layout-cell layout-item-4" style="width: 30%;">
                                        <asp:Label ID="label_CompanyEmail" AssociatedControlID="txt_CompanyEmail" runat="server" Text="Company Email:" />
                                    </div>
                                    <div class="art-layout-cell layout-item-4" style="width: 60%;">
                                        <telerik:RadTextBox ID="txt_CompanyEmail" runat="server" InvalidStyleDuration="100" SelectionOnFocus="SelectAll" Width="80%" Text='<%#Bind("CompanyEmail")%>'>
                                            <HoveredStyle Font-Bold="True" ForeColor="#FF3300" />
                                            <EnabledStyle BackColor="Azure" PaddingRight="10px" />
                                        </telerik:RadTextBox>
                                        <asp:RequiredFieldValidator ID="CompanyEmailRequired" runat="server" ControlToValidate="txt_CompanyEmail" ErrorMessage="*" ForeColor="Red" />
                                    </div>
                                </div>
                            </div>
                            <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                    <div class="art-layout-cell layout-item-4" style="width: 30%;">
                                        <asp:Label ID="label_CompanyAttachments" runat="server" Text="Company Attachments:" />
                                    </div>
                                    <div class="art-layout-cell layout-item-4" style="width: 70%;">
                                        <telerik:RadGrid ID="RadGrid_CompanyAttachments" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
                                            AllowFilteringByColumn="True" AllowSorting="True" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" DataSourceID="SqlDataSource_CompanyAttachments"
                                            EnableEmbeddedSkins="False" PageSize="5" ShowStatusBar="True">
                                            <MasterTableView DataSourceID="SqlDataSource_CompanyAttachments" DataKeyNames="CompanyID" AutoGenerateColumns="false" AllowPaging="true" PageSize="10" CommandItemDisplay="Top">
                                                <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Add New Company Attachment" RefreshText="Refresh" />
                                                <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                                                    <HeaderStyle Width="20px" />
                                                </RowIndicatorColumn>
                                                <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                                                    <HeaderStyle Width="20px" />
                                                </ExpandCollapseColumn>
                                                <Columns>
                                                    <telerik:GridTemplateColumn HeaderText="No." AllowFiltering="false">
                                                        <ItemTemplate>
                                                            <asp:Label ID="IDLabel" runat="server" Text=""></asp:Label>
                                                        </ItemTemplate>
                                                        <HeaderStyle HorizontalAlign="Center" Width="40px" />
                                                        <ItemStyle HorizontalAlign="Center" Width="40px" />
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridBoundColumn DataField="AttachmentName" FilterControlAltText="Filter AttachmentName column" FilterControlWidth="100%" HeaderText="AttachmentName" SortExpression="AttachmentName"
                                                        AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" UniqueName="AttachmentName">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="AttachmentPath" Visible="false" FilterControlAltText="Filter AttachmentPath column" HeaderText="AttachmentPath" SortExpression="AttachmentPath" UniqueName="AttachmentPath">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="CompanyID" Visible="false" DataType="System.Int64" FilterControlAltText="Filter CompanyID column" HeaderText="CompanyID" SortExpression="CompanyID" UniqueName="CompanyID">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderText="Edit" UniqueName="EditCommand" EditImageUrl="../../Design/MeStyle/Grid/Edit.gif" />
                                                </Columns>
                                                <EditFormSettings>
                                                    <EditColumn FilterControlAltText="Filter EditCommandColumn column" />
                                                    <FormTemplate>
                                                        <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                                            <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                                                <div class="art-layout-cell layout-item-4" style="width: 100%; padding-left: 10px;">
                                                                    <telerik:RadButton ID="button_Update" runat="server" Width="100px" Text='<%# IIf((TypeOf (Container) Is GridEditFormInsertItem), "Add", "Update")%>'
                                                                        CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>' />
                                                                    <telerik:RadButton ID="button_Cancel" Width="100px" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" />
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </FormTemplate>
                                                </EditFormSettings>
                                            </MasterTableView>
                                            <FilterMenu EnableImageSprites="False"></FilterMenu>
                                        </telerik:RadGrid>
                                    </div>
                                </div>
                                <div class="art-layout-cell layout-item-1" style="width: 100%;">
                                    <div class="art-layout-cell layout-item-4" style="width: 100%; padding-left: 10px;">
                                        <telerik:RadButton ID="button_Update" runat="server" Width="100px" Text='<%# IIf((TypeOf (Container) Is GridEditFormInsertItem), "Add", "Update")%>'
                                            CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>' />
                                        <telerik:RadButton ID="button_Cancel" Width="100px" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" />
                                    </div>
                                </div>
                            </div>
                        </FormTemplate>
                    </EditFormSettings>
                    <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" />
                </MasterTableView>
                <FilterItemStyle HorizontalAlign="Center" />
                <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" />
                <FilterMenu EnableImageSprites="False" />
                <HeaderContextMenu EnableEmbeddedSkins="false" />
            </telerik:RadGrid>



First time using telerik product,
the second radgrid (RadGrid_CompanyAttachments) not displaying while creating a new comapny.
how to fix this issue.


thank you....

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Dec 2013, 02:31 PM
Hi Mohammed,

I tried your code and it works fine at my end please try binding the radgrid using Advanced Data-binding (using NeedDataSource event). Below is a sample code snippet that i tried.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
    AllowPaging="true">
    <MasterTableView DataKeyNames="OrderID" CommandItemDisplay="Top">
        <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Add New Company"
            RefreshText="Refresh" />
        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
            <HeaderStyle Width="20px" />
        </RowIndicatorColumn>
        <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
            <HeaderStyle Width="20px" />
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridBoundColumn DataField="OrderID" FilterControlAltText="Filter OrderID column"
                HeaderText="Name" SortExpression="OrderID" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo"
                ShowFilterIcon="false" UniqueName="OrderID">
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="ShipCity" FilterControlAltText="Filter ShipCity column"
                HeaderText="ShipCity" SortExpression="ShipCity" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                ShowFilterIcon="false" UniqueName="ShipCity">
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridBoundColumn>
            <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderText="Edit" UniqueName="EditCommand" />
        </Columns>
        <EditFormSettings EditFormType="Template">
            <EditColumn FilterControlAltText="Filter EditCommandColumn column" />
            <FormTemplate>
                <table>
                    <tr>
                        <td>
                            OrderID:
                        </td>
                        <td>
                            <telerik:RadTextBox ID="txt_OrderID" runat="server" Text='<%#Bind("OrderID")%>'>
                                <HoveredStyle Font-Bold="True" ForeColor="#FF3300" />
                                <EnabledStyle BackColor="Azure" PaddingRight="10px" />
                            </telerik:RadTextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txt_OrderID"
                                ErrorMessage="*" ForeColor="Red" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            ShipCity:
                        </td>
                        <td>
                            <telerik:RadTextBox ID="txt_ShipCity" runat="server" Text='<%#Bind("ShipCity")%>'>
                                <HoveredStyle Font-Bold="True" ForeColor="#FF3300" />
                                <EnabledStyle BackColor="Azure" PaddingRight="10px" />
                            </telerik:RadTextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txt_ShipCity"
                                ErrorMessage="*" ForeColor="Red" />
                        </td>
                    </tr>
                    <br />
                    <tr>
                        <td>
                            <telerik:RadGrid ID="RadGrid2" runat="server" OnNeedDataSource="RadGrid2_NeedDataSource"
                                AllowPaging="true">
                                <MasterTableView DataKeyNames="CustomerID" CommandItemDisplay="Top">
                                    <Columns>
                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderText="Edit" UniqueName="EditCommand" />
                                    </Columns>
                                    <EditFormSettings EditFormType="Template">
                                        <EditColumn FilterControlAltText="Filter EditCommandColumn column" />
                                        <FormTemplate>
                                            CustomerID:
                                            <telerik:RadTextBox ID="txt_CustomerID" runat="server" Text='<%#Bind("CustomerID")%>'>
                                                <HoveredStyle Font-Bold="True" ForeColor="#FF3300" />
                                                <EnabledStyle BackColor="Azure" PaddingRight="10px" />
                                            </telerik:RadTextBox>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txt_CustomerID"
                                                ErrorMessage="*" ForeColor="Red" />
                                            <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                                runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                            </asp:Button
                                            <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                                CommandName="Cancel"></asp:Button>
                                        </FormTemplate>
                                    </EditFormSettings>
                                </MasterTableView>
                                <FilterMenu EnableImageSprites="False">
                                </FilterMenu>
                            </telerik:RadGrid>
                            <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                            </asp:Button
                            <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                CommandName="Cancel"></asp:Button>
                        </td>
                    </tr>
                </table>
            </FormTemplate>
        </EditFormSettings>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    RadGrid1.DataSource = GetDataTable("SELECT OrderID,ShipCity FROM Orders");
}
 
protected void RadGrid2_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    RadGrid radgrid = (RadGrid)sender;
    radgrid.DataSource = GetDataTable("SELECT CustomerID FROM Customers");
}
public DataTable GetDataTable(string query)
{
    String ConnString = ConfigurationManager.ConnectionStrings["Northwind_newConnectionString3"].ConnectionString;
    SqlConnection conn = new SqlConnection(ConnString);
    SqlDataAdapter adapter = new SqlDataAdapter();
    adapter.SelectCommand = new SqlCommand(query, conn);
 
    DataTable myDataTable = new DataTable();
 
    conn.Open();
    try
    {
        adapter.Fill(myDataTable);
    }
    finally
    {
        conn.Close();
    }
 
    return myDataTable;
}

Thanks,
Princy
Tags
Grid
Asked by
Mohammed
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or