Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!
I am new to .Net.
I have this problem.
I had a textbox outside grid which maintains some integer value (ProductID range)
Inside the grid I have taxtboxes which needs to be entered only the integer values less than or equal to the value in the textbox outside the grid.

I tried using Compare validator and regex validatior, But unable to get the output what I want.

Any help Please..
Thanks in advance....
Posted

Easiest would be if you use Javascript/jQuery to do that.

Have a onchange event of Grid textbox wired up to a Javascript method. In that compare the value entered and based on it display the prompt or take any necessary action.
 
Share this answer
 
Use Javascript.

Say the id of the outside textbox is txtoutside.

Now OnBlur or OnChange event write

onchange ="javascript:return checkValue(this);"

function checkValue(obj)
{
   if(obj){
      var elemoutside = document.getElementById('txtoutside');
      var thistextval = parseInt(obj.value);
      var outsideval = parseInt(elemoutside);
      if(outsideval <= thistextval) {
          
          return true;
      }
   }
   alert('Invalid entry');
   return false;
}


this would help I think.
 
Share this answer
 
You need to write the javascript on keyPress event of textbox which is in Template Field
Just use event.keychar in script to check whcih key get pressed.
allow only numric keys (keyCode = 47-56)

regards
 
Share this answer
 
Comments
pkarthionline 26-Mar-14 7:47am    
i have same problem =>
http://www.codeproject.com/Questions/749988/hi-how-to-validate-gridview-databound-textbox-valu

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900