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

FormTemplate doesn't close upon insert

2 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joey
Top achievements
Rank 1
Joey asked on 24 Sep 2008, 05:17 AM

I have the following code on my page. When I click the "Add new record" button the template form shows and I enter my data and click the Insert button. The Ajax postback occurs, however the formtemplate does not auto hide nor does the RadGrid refresh with the new row. What's the problem?

<telerik:RadAjaxPanel runat="server" EnableAJAX="true" EnableEmbeddedScripts="true">

<telerik:RadGrid ID="grdConfigurations" runat="server" OnNeedDataSource="grdConfigurations_NeedDataSource">

<MasterTableView DataKeyNames="ConfigurationGuid" EditMode="EditForms" CommandItemDisplay="top" AllowAutomaticInserts="true" AutoGenerateColumns="False">

<EditFormSettings EditFormType="Template">

<FormTemplate>

...

<

asp:Button ID="btnUpdate" Text='<%# ((bool)DataBinder.Eval(Container, "OwnerTableView.IsItemInserted")) ? "Insert" : "Update" %>'

runat="server" CommandName='<%# ((bool)DataBinder.Eval(Container, "OwnerTableView.IsItemInserted")) ? "PerformInsert" : "Update" %>'></asp:Button>

</FormTemplate>

</EditFormSettings>

</MasterTableView>

</telerik:RadGrid>

</telerik:RadAjaxPanel>

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Sep 2008, 05:44 AM
Hello Joey,

Hope you are not manually inserting data, in which case you would have to set AllowAutomaticInserts to false. On enabling AutomaticInserts,  after inserting, to close the form you can set RadGrid1.MasterTableView.IsItemInserted = false and then rebind the grid using RadGrid1.Rebind().

Thanks
Princy.
0
Joey
Top achievements
Rank 1
answered on 24 Sep 2008, 07:40 PM

I forgot to include the

OnNeedDataSource

="grdConfigurations_NeedDataSource"

in my original post, i've updated it. According to the documentation that event is supposed to fire when:

"When an edit command is fired."
"Immediately after any Update, Delete, or Insert command event handlers finish execution. You can cancel these operations by handling ItemCommand event and assigning false to the e event argument's Canceled property. "

So while your code may indeed work i shouldn't have to do anything to get the default behavior i'm expecting.
Tags
Grid
Asked by
Joey
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Joey
Top achievements
Rank 1
Share this question
or