View/Edit/Copy/Delete Error after Grid_Inserting Event

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
prem01628
User
Posts: 23

View/Edit/Copy/Delete Error after Grid_Inserting Event

Post by prem01628 »

I make all the changes in Template Files as suggested in link http://www.hkvforums.com/viewtopic.php?f=7&t=38538

Grind Inserting Sever Event Issued Solved but

now Add/View/Edit/Copy/Delete not working. Now getting new same Errors in all links are

Server Error in '/test' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'GetGridFormValues' does not exist in the current context

Source Error:
Line 30: // To reject grid insert, set return value to FALSE
Line 31:
Line 32: var rsnew = GetGridFormValues(); // Get the form values of the new records as an array of array
Line 33:
Line 34: //ew_End(rsnew); // Print the records and end the script

Source File: c:\inetpub\wwwroot\test\saledetailsedit.cshtml Line: 32
Source File: c:\inetpub\wwwroot\test\saledetailsview.cshtml Line: 32
Source File: c:\inetpub\wwwroot\test\saledetailsadd.cshtml Line: 32
Source File: c:\inetpub\wwwroot\test\saledetailsdelete.cshtml Line: 32

Please help in this regard..... i will be very thankful for this ....... Regards


motfs
User
Posts: 258

Post by motfs »

Double check if <table>list.cs include this function:

public List<OrderedDictionary> GetGridFormValues() {
...
}

If not, your modification is not correct (most likely, this file "list-script-function.cshtml"). You may post what you have modified.


prem01628
User
Posts: 23

Post by prem01628 »

all changes in //**** lines

  1. page-class.cs:

    	<!--## if (id != "master") { // ASPX ##-->
    <!--##~GetServerEvent("Table","Grid_Inserting","",true)##-->    //***
    <!--##~GetServerEvent("Table","Grid_Inserted","",true)##-->    //***
    <!--##~GetServerEvent("Table","Grid_Updating","",true)##-->    //***
    <!--##~GetServerEvent("Table","Grid_Updated","",true)##-->    //***
  1. list-script-function.cshtml:

    // Perform Grid Add
    public bool GridInsert() {
    	int addcnt = 0;
    	bool bGridInsert = false;
    	
    	<!--## //*** if (SYSTEMFUNCTIONS.ServerScriptExist("Table","Grid_Inserting")) { ##-->
    	<!--## if (CTRL.CtrlID == "list" && SYSTEMFUNCTIONS.ServerScriptExist("Table","Grid_Inserting")) {
    	//***	##-->
    	// Call Grid Inserting event
       .......
    
    // Get all form values of the grid
    //*** public OrderedDictionary GetGridFormValues() {
    public List<OrderedDictionary> GetGridFormValues() { //***
    
    // Get row count
    	ObjForm.Index = -1;
    	int rowcnt = ew_ConvertToInt(ObjForm.GetValue(FormKeyCountName));
    	if (ew_Empty(rowcnt) || !Information.IsNumeric(rowcnt))
    		rowcnt = 0;
    	//*** var rows = new OrderedDictionary();
    	var rows = new List<OrderedDictionary>(); //***
    	// Loop through all records
    	for (int rowindex = 1; rowindex <= rowcnt; rowindex++) {
    
    		// Load current row values
    		ObjForm.Index = rowindex;
    
    		string rowaction = ObjForm.GetValue(FormActionName);
    		if (rowaction != "delete" && rowaction != "insertdelete") {
    
    			LoadFormValues(); // Get form values
    
    			if (rowaction == "insert" && EmptyRow()) {
    				// Ignore
    			} else {
    				//*** rows[rowindex] = GetFieldValues("FormValue"); // Return row as array
    				rows.Add(GetFieldValues("FormValue")); // Return row as array //***
    			}
    		}
    	}
    	return rows; // Return as array of array
    }
  1. aspxfn.cs:

    // Get field values
    //*** public Dictionary<string, object> GetFieldValues(string name) {
    public OrderedDictionary GetFieldValues(string name) { //***
    	//*** var values = new Dictionary<string, object>();
    	var values = new OrderedDictionary(); //***
  1. Grid Inserting Server event code...

// Grid Inserting event
public bool Grid_Inserting() {
// Enter your code here
// To reject grid insert, set return value to FALSE

var rsnew = GetGridFormValues(); // Get the form values of the new records as an array of array
//ew_End(rsnew); // Print the records and end the script
int sum = 0;
 foreach (OrderedDictionary row in rsnew) // Loop through the new records
	sum += Convert.ToInt32(row["amt"]);
if (sum < 1000) {
// To cancel, set return value to false
	FailureMessage = "The total amount must be greater than 1000.";
	return false;
}
 return true;

}

Please give the solution.


prem01628
User
Posts: 23

Post by prem01628 »

If i remove code from Grid Inserting Sever Event, it works fine.......

  1. Grid Inserting Server event code...

// Grid Inserting event
public bool Grid_Inserting() {
// Enter your code here
// To reject grid insert, set return value to FALSE

return true;
}


motfs
User
Posts: 258

Post by motfs »

  1. page-class.cs:

    <!--## if (id != "master") { // ASPX ##-->

<!--##GetServerEvent("Table","Grid_Inserting","",true)##-->
<!--##GetServerEvent("Table","Grid_Inserted","",true)##-->
<!--##GetServerEvent("Table","Grid_Updating","",true)##-->
<!--##*GetServerEvent("Table","Grid_Updated","",true)##-->

Move this <!--##GetServerEvent("Table","Grid_Inserting","",true)##--> under <!--## if (id == "list") { ##--> instead of <!--## if (id != "master") { // ASPX ##-->.

So, try to modify the page-class.cs like this (so as not to generate the code in Edit/Add page):
<!--## if (id == "list") { ##-->
<!--##GetServerEvent("Table","Row_CustomAction",id,true)##-->
<!--##GetServerEvent("Table","Page_Exporting",id,true)##-->
<!--##GetServerEvent("Table","Row_Export",id,true)##-->
<!--##GetServerEvent("Table","Page_Exported",id,true)##-->
<!--##GetServerEvent("Table","Grid_Inserting","",true) //##-->
<!--##GetServerEvent("Table","Grid_Inserted","",true) //
##-->
<!--##GetServerEvent("Table","Grid_Updating","",true) //##-->
<!--##GetServerEvent("Table","Grid_Updated","",true) //
##-->
...


prem01628
User
Posts: 23

Post by prem01628 »

Thanks motfs for this helping hand.......

above said changes solved my problem........ thanks a lot......


Post Reply