Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
script var can just run once?
posted

 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?