Two Different edit Popup form

7 posts, 0 answers
  1. Mirco
    Mirco avatar
    3 posts
    Member since:
    Jul 2012

    Posted 02 Jul 2012 Link to this post

    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?

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Jul 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mirco
    Mirco avatar
    3 posts
    Member since:
    Jul 2012

    Posted 02 Jul 2012 Link to this post

    No, I want different user controls only in EDIT.

    With two different edit-buttons in the gridRow that open different Popup webusercontrols
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Jul 2012 Link to this post

    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.
  6. Giorgos
    Giorgos avatar
    18 posts
    Member since:
    Apr 2013

    Posted 23 Jul 2014 in reply to Shinu Link to this post

    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.



  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Jul 2014 in reply to Giorgos Link to this post

    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
  8. Giorgos
    Giorgos avatar
    18 posts
    Member since:
    Apr 2013

    Posted 23 Jul 2014 in reply to Shinu Link to this post

    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";
       }
    }

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017