Help needed getting data from form template

6 posts, 1 answers
  1. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 11 Feb 2009 Link to this post

    I have a radgrid with <formtemplate>, and 2 buttons save and cancel.

    How do I make the save button either run the insert code or the save new code. I'm not using any of the automatice operations as I have to use a dataclass

    I have the example ManualInsertUpdateUsingFormTemplate, and it has the following that I cant decypher nor make sense of. 

    <

     

    asp:Button ID="btnUpdate" Text='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "Insert" : "Update" %> 

     

    runat="server" CommandName='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "PerformInsert" : "Update" %>'>

     

    </asp:Button>

    The page has reference to 

    <%

    @ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="radG" %>

     

     

     

     

    but I dont want to add any extra that I dont need too.

    I have also found this, but it still wont work   <%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'

    Can anyone offer any help please.

    Andy

     

     

     

     

     

     

     

     

     

     

     

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

    Posted 12 Feb 2009 Link to this post

    Hi,

    I guess you are refering to the codelibrary submission done by Princy. In that the same one button is used to perform Insert as well as Update operation. The Text and CommandName of the button is switched between Insert and Update depending on whether the Grid is in Insert mode or not.

    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 12 Feb 2009 Link to this post

    Yes I see that, but how is it done, and how can I change the values of my template buttons to insert and update.
    The code in the aspx page to do the swap wont run without the radgrid.net2 being registered.

    In the example it a c# file, I'm uging VB, and cant see how to do the same thing.

    Andy
  5. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 13 Feb 2009 Link to this post

    I have my template form with 3 buttons, add, update and cancel. They all work and run code. How do I hide add button for updates, and hide the update button for add.

    ANdy
  6. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Feb 2009 Link to this post

    Hello Andy,

    You can try out the following code to switch button texts and commandnames according to the modes(Edit/Insert):
    aspx:
    <FormTemplate> 
                   <asp:Button ID="btnUpdate" Text='<%#iif(TryCast(Container, GridItem).OwnerTableView.IsItemInserted, "PerformInsert","Update")  %>' runat="server" CommandName='<%# iif(TryCast(Container, GridItem).OwnerTableView.IsItemInserted, "PerformInsert", "Update" )%>'
                   </asp:Button> 
                   <asp:Button ID="Button1" runat="server" Text="Cancel" CommandName="Cancel" />                 
    </FormTemplate> 

    Thanks
    Princy.
  7. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 13 Feb 2009 Link to this post

    Hi Princy.

    This worked a treat first time, thank you.

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