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

[Solved] Edit Form Issue

1 Answer 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Melanie
Top achievements
Rank 1
Melanie asked on 03 Apr 2013, 12:46 PM
I have a radgrid (rg1) that has a custom edit form. In the custom edit form for rg1, I have another radgrid(rg2). In rg2 I need to use another custom edit form and this is where the issue begins. In order to get rg2 the data it needs to populate I had to use a button since the data did not exist until after the form is loaded, if there is a better way please share as the button does not feel like a good solution. So once I press the button rg2 now has data and is displayed. When I press the "add new record" button in rg2 I want it to show my custom edit form like it does in rg1. What it is does however is clears the data from rg2. Now if I click the button used to show rg2 in the first place it now opens but not with the data but the edit form instead. So how do I make rg2 show the custom edit form without resetting rg2 and having to press the button again to see it? code for both below:


rg1:

<telerik:RadGrid ID="contactsGrid" runat="server" OnNeedDataSource="contactsGrid_NeedDataSource"
                AllowSorting="False" AllowFilteringByColumn="true"  Skin="Default" GridLines="Both" AutoGenerateColumns="False"
                ShowFooter="false" AllowPaging="true" PageSize="25" PagerStyle-AlwaysVisible="true"
                OnUpdateCommand="contactsGrid_UpdateCommand" OnInsertCommand="contactsGrid_InsertCommand"
                EnableLinqExpressions="false" OnDeleteCommand="contactsGrid_DeleteCommand" GroupingEnabled="True" ShowGroupPanel="True"
                GroupPanel-Enabled="True">
                <ClientSettings AllowDragToGroup="True"/>
                <PagerStyle Mode="NextPrevNumericAndAdvanced" Position="TopAndBottom" HorizontalAlign="Center" />
                <MasterTableView AllowMultiColumnSorting="true" CommandItemDisplay="Top" CommandItemSettings-ShowRefreshButton="False" DataKeyNames="contact_id"
                    NoMasterRecordsText="No current contacts." TableLayout="Fixed">
                    <RowIndicatorColumn Visible="False">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>
                    <Columns>
                        <telerik:GridEditCommandColumn UniqueName="btnEdit" ButtonType="ImageButton" Resizable="False" >
                            <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                            <HeaderStyle Width="50px" />
                        </telerik:GridEditCommandColumn>
                        <telerik:GridBoundColumn DataField="contact_id" HeaderText="CONTACT_ID" UniqueName="CONTACT_ID"
                            AllowFiltering="True" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" >
                            <HeaderStyle Width="100px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="CONTACT_ORG" HeaderText="CONTACT_ORG" UniqueName="CONTACT_ORG"
                            AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" Groupable="True" >
                            <HeaderStyle Width="160px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="LOCATION_NAME" HeaderText="LOCATION_NAME" UniqueName="LOCATION_NAME"
                            AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" Groupable="True" >
                            <HeaderStyle Width="160px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="CONTACT_NAME" HeaderText="CONTACT_NAME" UniqueName="CONTACT_NAME"
                            AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" Groupable="True" >
                            <HeaderStyle Width="160px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="PHONE" UniqueName="PHONE" HeaderText="PHONE"
                            AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" Groupable="True" >
                            <HeaderStyle Width="150px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ALT_PHONE" HeaderText="ALT_PHONE" UniqueName="ALT_PHONE"
                            AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" Groupable="True" >
                            <HeaderStyle Width="150px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="CELL" HeaderText="CELL" UniqueName="CELL" AllowFiltering="true"
                        AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" Groupable="True" >
                            <HeaderStyle Width="150px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="FAX" UniqueName="FAX" HeaderText="FAX" AllowFiltering="true"
                        AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" Groupable="True" >
                            <HeaderStyle Width="150px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="DSN" HeaderText="DSN" UniqueName="DSN" AllowFiltering="true"
                        AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" Groupable="True" >
                            <HeaderStyle Width="100px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="EMAIL" HeaderText="EMAIL" UniqueName="EMAIL"
                            AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" Groupable="True" >
                            <HeaderStyle Width="200px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="COMMENTS" HeaderText="COMMENTS" UniqueName="COMMENTS"
                            AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" Groupable="True" >
                            <HeaderStyle Width="160px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="CONTACT_SRV" HeaderText="CONTACT_SRV" UniqueName="CONTACT_SRV"
                            AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" Groupable="True" >
                            <HeaderStyle Width="100px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="GROUP_ID" HeaderText="GROUP ID" UniqueName="GROUP_ID"
                            AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" Groupable="True" >
                            <HeaderStyle Width="160px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="GROUP_NAME" HeaderText="GROUPS" UniqueName="GROUP_NAME"
                            AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" Groupable="True" >
                            <HeaderStyle Width="160px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="LAST_UPDATED" HeaderText="LAST_UPDATED" UniqueName="LAST_UPDATED"
                            DataType="System.DateTime" AllowFiltering="false" DataFormatString="{0:MM/dd/yyyy}" Groupable="True" >
                            <HeaderStyle Width="100px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridButtonColumn ConfirmText="Delete this contact?" ConfirmDialogType="RadWindow"
                            ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                            UniqueName="DeleteColumnContacts" Visible="true">
                            <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                            <HeaderStyle Width="50px" />
                        </telerik:GridButtonColumn>
                    </Columns>
                    <EditFormSettings UserControlName="EditContact.ascx" EditFormType="WebUserControl">
                        <EditColumn UniqueName="EditCommandColumn1" >
                        </EditColumn>
                    </EditFormSettings>
                </MasterTableView>
                <EditItemStyle CssClass="EditFormHeader"></EditItemStyle>
                <ValidationSettings CommandsToValidate="PerformInsert, Update" />
            </telerik:RadGrid>


rg2:

<td>
                                    <asp:Button Visible='<%# !(DataItem is GridInsertionObject) %>' ID="editGroups" runat="server"
                                        Text="Edit Groups" OnClick="GroupMember" />
                                    <telerik:RadGrid Visible='<%# !(DataItem is GridInsertionObject) %>' ID="groupMemberGrid"
                                        runat="server" AllowSorting="False" AllowFilteringByColumn="false" Skin="Default"
                                        GridLines="Both" AutoGenerateColumns="False" ShowFooter="false" EnableLinqExpressions="false"
                                        OnDeleteCommand="groupMemberGrid_DeleteCommand">
                                        <GroupingSettings CaseSensitive="false" />
                                        <MasterTableView AllowMultiColumnSorting="false" CommandItemDisplay="Top" DataKeyNames="group_id"
                                            NoMasterRecordsText="Not a member of any groups." TableLayout="Fixed">
                                            <RowIndicatorColumn Visible="False">
                                                <HeaderStyle Width="20px"></HeaderStyle>
                                            </RowIndicatorColumn>
                                            <Columns>
                                                <telerik:GridButtonColumn ConfirmText="Delete this group?" ConfirmDialogType="RadWindow"
                                                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                                                    UniqueName="DeleteGroup" Visible="true">
                                                    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                                                    <HeaderStyle Width="50px" />
                                                </telerik:GridButtonColumn>
                                                <telerik:GridBoundColumn DataField="GROUP_ID" HeaderText="Group ID" UniqueName="GROUP_ID"
                                                    AllowFiltering="True">
                                                    <HeaderStyle Width="100px" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="GROUP_NAME" HeaderText="Group Name" UniqueName="GROUP_NAME"
                                                    AllowFiltering="false">
                                                    <HeaderStyle Width="160px" />
                                                </telerik:GridBoundColumn>
                                            </Columns>
                                            <EditFormSettings UserControlName="AddToGroup.ascx" EditFormType="WebUserControl">
                                                <EditColumn UniqueName="EditCommandColumn2">
                                                </EditColumn>
                                            </EditFormSettings>
                                        </MasterTableView>
                                        <EditItemStyle CssClass="EditFormHeader"></EditItemStyle>
                                        <ValidationSettings CommandsToValidate="Delete" />
                                    </telerik:RadGrid>
                                </td>

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 08 Apr 2013, 10:56 AM
Hi Robert,

From the code provided it is not pretty clear how is the second grid being populated. Could you please elaborate more on that matter? You can try populating the grid in the page load event of the EditContact user control. Give this suggestion a try and let us know of the result.

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.
Tags
Grid
Asked by
Melanie
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or