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

Two Different edit Popup form

6 Answers 139 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mirco
Top achievements
Rank 1
Mirco asked on 02 Jul 2012, 05:48 AM

Is possible open two different Popup Edit Form (EditMode="PopUp") in one RadGrid?
For each row adding TWO button like:
<telerik:GridEditCommandColumn ItemStyle-Width="1%" UniqueName="EditCommandColumn1" ButtonType="ImageButton" EditImageUrl="../../file/edit.gif" CancelText="Cancel" EditText="Edit" />

open two (but also three or four) different WebUserControl (file .ascx) that on "OK" button return values in the standard
"Private Sub RadGrid1_UpdateCommand" function, easily like the normal edit popup-mode

??

Is possible? Any example?

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Jul 2012, 06:05 AM
Hello Mirco,

I suppose you want to show different user controls on edit and insert. Here is the sample code.
C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
        if (e.CommandName == RadGrid.InitInsertCommandName)
        {
            e.Item.OwnerTableView.EditFormSettings.UserControlName = "WebUserControl3.ascx";
        }
        if (e.CommandName == RadGrid.EditCommandName)
        {
            e.Item.OwnerTableView.EditFormSettings.UserControlName = "WebUserControl2.ascx";
        }
}

Also take a look at the following help documentation.
Different Edit Forms on Edit and Insert.

Thanks,
Shinu.
0
Mirco
Top achievements
Rank 1
answered on 02 Jul 2012, 07:07 AM
No, I want different user controls only in EDIT.

With two different edit-buttons in the gridRow that open different Popup webusercontrols
0
Shinu
Top achievements
Rank 2
answered on 03 Jul 2012, 04:25 AM
Hello Mirco,

One suggestion is you can use tow GridButtonCloumns with different CommandName and show different usercontrols in ItemCommand event. Here is the sample code.
aspx:
<telerik:GridButtonColumn  CommandName="Edit" Text="Edit" ButtonType="LinkButton"></telerik:GridButtonColumn>
<
telerik:GridButtonColumn  CommandName="EditCommand"  Text="edit" ButtonType="LinkButton"></telerik:GridButtonColumn>
C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
 if (e.CommandName == "Edit")
 {
  RadGrid1.MasterTableView.EditFormSettings.UserControlName = "WebUserControl2.ascx";
 }
 if (e.CommandName == "EditCommand")
 {
  RadGrid1.MasterTableView.EditFormSettings.UserControlName = "WebUserControl1.ascx";
 }
}

Thanks,
Shinu.
0
Giorgos
Top achievements
Rank 1
answered on 23 Jul 2014, 11:17 AM
Shinu, I am trying to do exactly what the original poster did. I 've tried to implement what you suggested, but it's
not working for me. 

Here is the code for the buttons:

            <telerik:GridTemplateColumn HeaderStyle-Width="70px">
                <ItemTemplate>                                  
                <asp:LinkButton ID="btnEditData" runat="server" CommandName="EditData">
                        <i class="icon-edit"></i>
                    </asp:LinkButton>                                                   
                <asp:LinkButton ID="btnEditAmounts" runat="server" CommandName="Edit">
                        <i class="fa fa-pencil"></i>
                    </asp:LinkButton>                         
</ItemTemplate>
         </telerik:GridTemplateColumn>

And here is the code inside OnItemCommand event:

if (e.CommandName == RadGrid.EditCommandName)
{
   grd.MasterTableView.EditFormSettings.UserControlName = "~/UserControls/Edit.ascx";
}              
else if (e.CommandName == "EditData")
{
   grd.MasterTableView.EditFormSettings.UserControlName = "~/UserControls/EditData.ascx";
}


Unfortunately, it is not working when command EditData is issued. When the user clicks on the corresponing
link button a postback is performed, the relevant piece of code is executed, but nothing happens.



0
Shinu
Top achievements
Rank 2
answered on 23 Jul 2014, 11:57 AM
Hi Giorgos,

The EditData is not opening because the Grid cannot identify it to be in Editmode since its not an EditCommand, hence first you have to set that row in edit. Please try the following:

C#:
if (e.CommandName == "EditData")
{
 e.Item.Edit = true;
 grd.MasterTableView.EditFormSettings.UserControlName = "~/UserControls/EditData.ascx";
 grdSample.Rebind();
}

Thanks,
Shinu
0
Giorgos
Top achievements
Rank 1
answered on 23 Jul 2014, 12:05 PM
Hi Shinu, thanx for your responce. Actually we came up with a more elegant solution:

<telerik:GridTemplateColumn HeaderStyle-Width="80px">
   <ItemTemplate>                               
      <asp:LinkButton ID="btnEditData" runat="server" CommandName="Edit" CommandArgument="Data">
         <i class="icon-edit"></i>
      </asp:LinkButton>                                                                                                   
      <asp:LinkButton ID="btnEditAmounts" runat="server" CommandName="Edit" CommandArgument="Amounts">
         <i class="fa fa-pencil"></i>
      </asp:LinkButton>                         
   </ItemTemplate>
</telerik:GridTemplateColumn>

and inside the ItemCommand event:

if (e.CommandName == RadGrid.EditCommandName)
{
   if ((string)e.CommandArgument == "Amounts")
   {
      grd.MasterTableView.EditFormSettings.UserControlName = "~/UserControls/Amounts.ascx";
   }
   else if ((string)e.CommandArgument == "Data")
   {
      grd.MasterTableView.EditFormSettings.UserControlName = "~/UserControls/Data.ascx";
   }
}

Tags
Grid
Asked by
Mirco
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mirco
Top achievements
Rank 1
Giorgos
Top achievements
Rank 1
Share this question
or