i define a client script for define the 2 cell value when i edit another cell,the value is came from the fuction name getPCode,it genearate a unique value in the table,here is the code :
<script type="text/javascript" language="javascript"> function BeforeEnterEditMode(gridName,cellID,newValue) { //get the cell var cell = igtbl_getCellById(cellID); var value1 = cell.Row.getCell(0).getValue(); var sessionID = "<%=getSession() %>"; var dcode = "<%=getPCode() %>"; if (value1 == null) { cell.Row.getCell(0).setValue(sessionID); sessionID = null; cell.Row.getCell(1).setValue(dcode); dcode = null; cell.endEdit(); } else { cell.Row.getCell(1).setValue("789"); } return 0; } </script>
i define the fuction getPCode in my .cs file ,as this :
protected string getPCode() { string PCode = string.Empty; //do some thing in db return PCode; }
i track the source code and find this getPCode() only one time,when i add a new empty row,the dcode value is the last value because the fuction getPCode() don't run,so can anybody tell me why?
Hello,
I am not sure I understand the whole scenario in details. What I can tell however is that var dcode = "<%=getPCode() %>"; is executed only once, at compile time and not each time it is accessed (<%= ... %> is just a shortcut for the ASP classic print), so maybe this interferes with the logic in some way?
<p>yes i want it run each time when i edit new empty row,so what can i do to make that var dcode = "<%=getPCode()%>;"
run in my logic ?</p>
can u tell me what can i do if i want do it on server side?can you give me some code of that?
Well, it's a bit tough since it is on the client and you need to do it on the server. The only thing I can think of is synchronous webmethod call and / or PageMethods:
http://blogs.msdn.com/robj/archive/2007/01/05/pagemethods-in-asp-net-ajax-1-0-rc.aspx