Hi..
I am working in ASP.NET and i want to use GridView with RangeValidator control. How can we use it and define all property for the GridView and RangeValidator?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Feb 3, 2012, 12:31 AM
RangeValidator for Age Field
RangeValidator validates the input to fall between the specified range of MinimumValue and MaximumValue property. We can also mention the validation data type through the Type property of the RangeValidator. The code for creating and binding a RangeValidator with GridView control is as follows
RangeValidator rangevalidator = new RangeValidator();
rangevalidator.ID = "RangeValidator1";
rangevalidator.ControlToValidate = "TextBox3";
rangevalidator.ErrorMessage = "Invalid Age";
rangevalidator.MaximumValue = "100";
rangevalidator.MinimumValue = "0";
rangevalidator.SetFocusOnError = true;
rangevalidator.Type = ValidationDataType.Integer;
e.Row.Cells[2].Controls.Add(rangevalidator);
Please refer the below link
http://www.aspdotnetcodes.com/GridView_Dynamic_Validation.aspx
Thanks