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

Two different edit forms

3 Answers 211 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bader
Top achievements
Rank 1
Bader asked on 09 Oct 2010, 04:26 PM
Hello,

I have Two questions (not related):
1) I'm wonder if I can build my radgrid control using two different edit forms and each edit form has its webusercontrol.
2) How can I change the edit form content depending on a column UniqueName , In others words, I have two

GridEditCommandColumn

 

 

's and depending on there UniqueNames I want to display different content in the edit-form. 

my radgid:

<telerik:RadGrid ID="ConcertsRadGrid" runat="server" Skin="WebBlue" AllowFilteringByColumn="false"
                    GridLines="None" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
                    ShowStatusBar="true"  OnPreRender="ConcertsRadGrid_PreRender" 
                    OnNeedDataSource="ConcertsRadGrid_NeedDataSource" 
                    onitemcommand="ConcertsRadGrid_ItemCommand1" >
                    <MasterTableView GridLines="None" Width="100%" Dir="RTL" CommandItemDisplay="None" DataKeyNames="CnsrtID">
                        <Columns>
                            <telerik:GridBoundColumn UniqueName="CType" HeaderText="<%$ Resources:Resource, PagesConcertsRadGridCTypeColumn %>" DataField="CType">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="CnsrtName" HeaderText="<%$ Resources:Resource, PagesConcertsRadGridCnsrtNameColumn %>" DataField="CnsrtName">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="Choirs" HeaderText="<%$ Resources:Resource, PagesConcertsRadGridChoirsColumn %>" DataField="Choirs">
                            </telerik:GridBoundColumn>
                            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn1" EditText="<%$ Resources:Resource, PagesConcertsRadGridViewCnsrtColumn %>">
                            </telerik:GridEditCommandColumn>
                            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn2" EditText="<%$ Resources:Resource, PagesConcertsRadGridViewCnsrtColumn %>">
                            </telerik:GridEditCommandColumn>
                        </Columns>
                        <EditFormSettings UserControlName="~/Pages/Concerts/ConcertsSubUserControl.ascx" EditFormType="WebUserControl">
                            <EditColumn UniqueName="EditCommandColumn1">
                            </EditColumn>
                        </EditFormSettings>
                    </MasterTableView>
                </telerik:RadGrid>

Please, I need your help,
It is apprecited to send me the modified code.

Regards,
Bader

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Oct 2010, 06:12 AM
Hello Beder,


Set different ComamndName for the  Edit columns. Now hook the ItemCommand event to grid and switch the user control after checking the e.CommandName in the server event. The same logic is used here for showing different forms for edit and insert.
Different edit forms on edit and insert



-Shinu.
0
Bader
Top achievements
Rank 1
answered on 11 Oct 2010, 10:58 AM
Hello,

Thank you for your reply,
But unfortunatily I looking for something else. As you can see in my code there is two edit columns:
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn1" EditText="<%$ Resources:Resource, PagesConcertsRadGridViewCnsrtColumn %>"> 
</telerik:GridEditCommandColumn
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn2" EditText="<%$ Resources:Resource, PagesConcertsRadGridViewCnsrtColumn %>"> 
</telerik:GridEditCommandColumn>
All I need is to set a different edit form (webusercontrols) for each edit column (Or, if is is not possible, how can I set one edit form but with different content).

Please, I need your help,
It is appreciated to send me the modified code.

Regards,
Bader
0
Shinu
Top achievements
Rank 2
answered on 12 Oct 2010, 11:02 AM
Hello Bader,


You could use GridButtonColumn as shown below and toggle the UserControlName to show different forms for editing.

aspx:
<Columns>                      
    <telerik:GridButtonColumn CommandName="first" Text="EditFirst">
    </telerik:GridButtonColumn>
    <telerik:GridButtonColumn CommandName="second" Text="EditFirst">
    </telerik:GridButtonColumn>
</Columns>


code:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
    if (e.CommandName == "first")
    {
        e.Item.OwnerTableView.EditFormSettings.UserControlName = "picture.ascx";
    }
    else if (e.CommandName == "second")
    {
        e.Item.OwnerTableView.EditFormSettings.UserControlName = "picture1.ascx";
    }
    e.Item.Edit = true;
    e.Item.OwnerTableView.Rebind();
}


Hope this helps,


-Shinu.
Tags
Grid
Asked by
Bader
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Bader
Top achievements
Rank 1
Share this question
or