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

Help needed getting data from form template

5 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andy Green
Top achievements
Rank 2
Andy Green asked on 11 Feb 2009, 07:33 PM
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

 

 

 

 

 

 

 

 

 

 

 

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 12 Feb 2009, 09:28 AM
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
0
Andy Green
Top achievements
Rank 2
answered on 12 Feb 2009, 10:06 AM
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
0
Andy Green
Top achievements
Rank 2
answered on 13 Feb 2009, 10:58 AM
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
0
Accepted
Princy
Top achievements
Rank 1
answered on 13 Feb 2009, 12:05 PM
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.
0
Andy Green
Top achievements
Rank 2
answered on 13 Feb 2009, 12:53 PM
Hi Princy.

This worked a treat first time, thank you.

Andy
Tags
Grid
Asked by
Andy Green
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 1
Andy Green
Top achievements
Rank 2
Princy
Top achievements
Rank 1
Share this question
or