protected void btnAddListValidation_Click(object sender, EventArgs e)
        {
            // ExStart:AddListValidation
            // Accessing the cells collection of the worksheet that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing "B1" cell
            WebCell cell = sheet.Cells[0, 1];

            // Putting value to "B1" cell
            cell.PutValue("Select Course:");

            // Accessing "C1" cell
            cell = sheet.Cells[0, 2];

            // Creating List validation for the "C1" cell
            cell.CreateValidation(ValidationType.List, true);

            // Adding values to List validation
            cell.Validation.ValueList.Add("Fortran");
            cell.Validation.ValueList.Add("Pascal");
            cell.Validation.ValueList.Add("C++");
            cell.Validation.ValueList.Add("Visual Basic");
            cell.Validation.ValueList.Add("Java");
            cell.Validation.ValueList.Add("C#");
            // ExEnd:AddListValidation
        }
Ejemplo n.º 2
0
        protected void btnAddCustomValidation_Click(object sender, EventArgs e)
        {
            // ExStart:AddCustomValidation
            // Accessing the cells collection of the worksheet that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing "B1" cell
            WebCell cell = sheet.Cells[0, 1];

            // Putting value to "B1" cell
            cell.PutValue("Date (yyyy-mm-dd):");

            // Accessing "C1" cell
            cell = sheet.Cells[0, 2];

            // Creating a custom expression validation for the "C1" cell
            cell.CreateValidation(ValidationType.CustomExpression, true);

            // Setting regular expression for the validation to accept dates in yyyy-mm-dd format
            cell.Validation.RegEx = @"\d{4}-\d{2}-\d{2}";
            // ExEnd:AddCustomValidation

            sheet.Cells.SetColumnWidth(1, new Unit(100, UnitType.Point));

            // Assigning the name of JavaScript function to OnValidationErrorClientFunction property of GridWeb
            GridWeb1.OnValidationErrorClientFunction = "ValidationErrorFunction";
        }
Ejemplo n.º 3
0
        private void InitGridWeb()
        {
            // ExStart:WriteClientSideScript
            // Assigning the name of JavaScript function to OnSubmitClientFunction property of GridWeb
            GridWeb1.OnSubmitClientFunction = "ConfirmFunction";

            // Assigning the name of JavaScript function to OnValidationErrorClientFunction property of GridWeb
            GridWeb1.OnValidationErrorClientFunction = "ValidationErrorFunction";

            // Accessing the cells collection of the worksheet that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing "B1" cell
            WebCell cell = sheet.Cells[0, 1];

            // Putting value to "B1" cell
            cell.PutValue("Date (yyyy-mm-dd):");

            // Accessing "C1" cell
            cell = sheet.Cells[0, 2];

            // Creating a custom expression validation for the "C1" cell
            cell.CreateValidation(ValidationType.CustomExpression, true);

            // Setting regular expression for the validation to accept dates in yyyy-mm-dd format
            cell.Validation.RegEx = @"\d{4}-\d{2}-\d{2}";
            // ExEnd:WriteClientSideScript
        }
Ejemplo n.º 4
0
        protected void btnAddDropDownListValidation_Click(object sender, EventArgs e)
        {
            // ExStart:AddDropDownListValidation
            // Accessing the cells collection of the worksheet that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing "B1" cell
            WebCell cell = sheet.Cells[0, 1];

            // Putting value to "B1" cell
            cell.PutValue("Select Degree:");

            // Accessing "C1" cell
            cell = sheet.Cells[0, 2];

            // Creating DropDownList validation for the "C1" cell
            cell.CreateValidation(ValidationType.DropDownList, true);

            // Adding values to DropDownList validation
            cell.Validation.ValueList.Add("Bachelor");
            cell.Validation.ValueList.Add("Master");
            cell.Validation.ValueList.Add("Doctor");
            // ExEnd:AddDropDownListValidation
        }