Показать сообщение отдельно
Старый 05.11.2008, 11:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,492 / 847 (79) +++++++
Регистрация: 28.10.2006
palleagermark: EP 2009: Edit a record outside a grid
Источник: http://palleagermark.blogspot.com/20...side-grid.html
==============

Here is what you can do if you want to edit a record that is not part of a grid.





The record needs to be shown through an AxForm control and on this control you can set the "AutoGenerateEditButton" to True to get an Edit/Update and Cancel button automatically added to the form.





Next you may need to add event handlers to these buttons if you want the system to do something special in case these are clicked.





This is how the event handler for update could look, if you want to run an additional action on the DataSet:





private
void AxForm_MyForm_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)


{



if (e.Exception == null)


{



// Run the approval code



this.MyDataSet.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("MYMethodOnTheDataSet");






// Redirect to the list of invoices



AxUrlMenuItem listpage = new
AxUrlMenuItem("MyMenuItem");


Response.Redirect(listpage.Url.OriginalString);


}


}





And here is how the code for the Cancel button could look:





private
void AxForm_MyForm_ItemCommand(object sender, DetailsViewCommandEventArgs e)


{



if (e.CommandName == "Cancel")


{



this.RedirectToPreviousPage();


}


}





The RedirectToPreviousPage method is a method you have to add yourself. It could look like this:


private
void RedirectToPreviousPage()


{



// Return to the previous page displayed.



if (!String.IsNullOrEmpty(AxWebSession.GetPreviousURL(this.Page)))


{


Response.Redirect(AxWebSession.GetPreviousURL(this.Page));


}



else


{



// The previous page is not available, so return to a known page.



// Use the URL Web Menu item from the AOT to specify which



// page will be displayed.



AxUrlMenuItem listpage = new
AxUrlMenuItem("MyMainPage");


Response.Redirect(listpage.Url.OriginalString);


}


}








And finally you must add you new event handler to the event handlers for the two buttons. This is done in the Page_Init method:





protected
void Page_Init(object sender, EventArgs e)


{



this.AxForm_MyForm.ItemUpdated += new
DetailsViewUpdatedEventHandler(AxForm_MyForm_ItemUpdated);



this.AxForm_MyForm.ItemCommand += new
DetailsViewCommandEventHandler(AxForm_MyForm_ItemCommand);


}



Источник: http://palleagermark.blogspot.com/20...side-grid.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.