Hi
We have a grid that, in edit mode, the user has the options to 'Save this record' or 'Save this record and add another'. When clicking the 2nd option, the current record should be persisted to the database and a new blank form should be presented to allow the user to enter more data. Very often we want to prepopulate the form based on the previous entry. I have the following code to do this:
protected
void
RadGrid1_InsertCommand(
object
source, GridCommandEventArgs e)
{
if
(e.CommandSource
is
LinkButton)
{
LinkButton sourceLinkButton = (LinkButton)e.CommandSource;
if
(sourceLinkButton.ID ==
"SaveThisRecordAndAddAnotherLinkButton"
)
{
e.Item.OwnerTableView.PerformInsert();
RadGrid1.MasterTableView.IsItemInserted =
true
;
//Prepare an IDictionary with the predefined values
System.Collections.Specialized.ListDictionary newValues =
new
System.Collections.Specialized.ListDictionary();
newValues[
"Remarks"
] =
"Test remarks"
;
//Insert the item and rebind
e.Item.OwnerTableView.InsertItem(newValues);
RadGrid1.Rebind();
Utils.Log(
"IsItemInserted:"
+ RadGrid1.MasterTableView.IsItemInserted);
}
else
{
RadGrid1.MasterTableView.IsItemInserted =
false
;
}
}
}
What I'm getting is:
- the current record is persisted correctly to the database
- NO new insert form is presented to the user
- a 2nd record with the prepopulated value "Test remarks" is added to the database
- the Utils.Log debug statement shows in the log that 'IsItemInserted' is set to true
As a test, I placed the statement '
RadGrid1.MasterTableView.IsItemInserted =
true
;
' in the Page_Load event and the grid loaded with the insert form open as expected.In contrast, if I place the same in the RadGrid1_PreRender event, no insert form appears.
I'm using RadControls_for_ASP.NET_AJAX_2010_1_415_dev_hotfix.zip.
Is the InsertCommand event too late in the page life cycle for 'IsItemInserted =
true
;
' to show the insert form?What's strange is that we have another web app (implemented in VB) on an earlier version of the Telerik controls and this method works fine!
Please help.