protected void GridCountryView_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { GridValidation.ValidateInt("CountryId", sender, e); GridValidation.ValidateLength("CountryName", 2, sender, e); GridValidation.ValidateLength("ImageThumbnailsPath", 2, sender, e); GridValidation.ValidateLength("ImageGalleryPath", 2, sender, e); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack && !this.GridWeb1.IsPostBack) { lblVersion.Text = GridWeb.GetVersion(); //Input values to B2:C3 cells in the active worksheet. GridWeb1.ActiveSheet.Cells["B2"].PutValue("This"); GridWeb1.ActiveSheet.Cells["C2"].PutValue("cannot"); GridWeb1.ActiveSheet.Cells["B3"].PutValue("be"); GridWeb1.ActiveSheet.Cells["C3"].PutValue("changed"); //Get the validations of the active sheet. var gridValidationCollection = GridWeb1.ActiveSheet.Validations; //Add data validation to range/area: B2:C3 GridValidation gv = gridValidationCollection.Add(new GridCellArea(1, 1, 2, 2)); //Set the validation type to custom server function. gv.ValidationType = GridValidationType.CustomServerFunction; //Set the server validation class which implements the GridCustomServerValidation interface. gv.ServerValidation = new MyServerValidation(); //Set the client validation function (written in JavaScript on client-side). //This function is compulsory to validate the data on client end on callback. gv.ClientValidationFunction = "ValidationErrorClientFunctionCallback"; //Set the error message string. gv.ErrorMessage = "Error found! You cannot change this value."; //Set the error title. gv.ErrorTitle = "Error"; } }
protected void GridProviderContactView_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { GridValidation.ValidateLength("Department", 2, sender, e); GridValidation.ValidateLength("Email", 2, sender, e); GridValidation.ValidateLength("FirstName", 2, sender, e); GridValidation.ValidateLength("LastName", 2, sender, e); GridValidation.ValidateLength("Phone", 2, sender, e); GridValidation.ValidateLength("MobilePhone", 2, sender, e); }
protected void GridB2BCustomerView_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { GridValidation.ValidateLength("Address", 2, sender, e); GridValidation.ValidateLength("Bank", 2, sender, e); GridValidation.ValidateLength("City", 2, sender, e); GridValidation.ValidateLength("Country", 2, sender, e); GridValidation.ValidateLength("IBAN", 2, sender, e); GridValidation.ValidateLength("Name", 2, sender, e); }
protected void GridBackOfficeContactView_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { GridValidation.ValidateLength("Address", 2, sender, e); GridValidation.ValidateLength("City", 2, sender, e); GridValidation.ValidateLength("CompanyName", 2, sender, e); GridValidation.ValidateLength("Country", 2, sender, e); GridValidation.ValidateLength("Email", 2, sender, e); GridValidation.ValidateLength("FirstName", 2, sender, e); GridValidation.ValidateLength("LastName", 2, sender, e); }
protected void GridProviderView_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { GridValidation.ValidateLength("Address", 2, sender, e); GridValidation.ValidateLength("Bank", 2, sender, e); GridValidation.ValidateLength("City", 2, sender, e); GridValidation.ValidateLength("Country", 2, sender, e); GridValidation.ValidateLength("IBAN", 2, sender, e); GridValidation.ValidateLength("PersonalIdentificationNumber", 2, sender, e); GridValidation.ValidateLength("Title", 2, sender, e); GridValidation.ValidateLength("BookingEmail", 2, sender, e); }
protected void GridTouristSiteView_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { GridValidation.ValidateInt("CountryId", sender, e); GridValidation.ValidateInt("RegionId", sender, e); GridValidation.ValidateInt("Stars", sender, e); GridValidation.ValidateLength("Description", 2, sender, e); GridValidation.ValidateLength("SiteCode", 6, sender, e); //GridValidation.ValidateLength("SiteName",2, sender, e); //GridValidation.ValidateLength("ImageThumbnailsPath",2, sender, e); //GridValidation.ValidateLength("ImageGalleryPath",2, sender, e); }
protected void GridUnitOfferView_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { GridValidation.ValidateInt("OfferCount", sender, e); GridValidation.ValidateLength("OfferCode", 3, sender, e); // GridValidation.ValidateFixedLength("SiteCode", sender, e); GridValidation.ValidateLength("OfferDescription", 2, sender, e); GridValidation.ValidateLength("OfferTitel", 2, sender, e); GridValidation.ValidateLength("ProviderNotice", 2, sender, e); GridValidation.ValidateLength("TourOperatorCode", 2, sender, e); GridValidation.ValidateLength("UnitCode", 2, sender, e); }
protected void GridCustomerView_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { GridValidation.ValidateLength("Adress", 2, sender, e); GridValidation.ValidateLength("Country", 2, sender, e); GridValidation.ValidateLength("EMail", 2, sender, e); GridValidation.ValidateLength("FirstName", 2, sender, e); GridValidation.ValidateLength("LastName", 2, sender, e); GridValidation.ValidateLength("MobilePhone", 2, sender, e); GridValidation.ValidateLength("Phone", 2, sender, e); GridValidation.ValidateLength("Place", 2, sender, e); GridValidation.ValidateLength("Salutation", 2, sender, e); GridValidation.ValidateLength("ZipCode", 2, sender, e); }
protected void btnAddDataValidation_Click(object sender, EventArgs e) { // ExStart:AddDataValidation // Access first worksheet GridWorksheet sheet = GridWeb1.WorkSheets[0]; // Access cell B3 GridCell cell = sheet.Cells["B3"]; // Add validation inside the gridcell // Any value which is not between 20 and 40 will cause error in a gridcell GridValidation val = cell.CreateValidation(GridValidationType.WholeNumber, true); val.Formula1 = "=20"; val.Formula2 = "=40"; val.Operator = GridOperatorType.Between; val.ShowError = true; val.ShowInput = true; // ExEnd:AddDataValidation Label1.Text = "Data Validation is added in cell B3. Any value which is not between 20 and 40 will cause error."; }
// input Entry protection/validation data private void initData() { // Forces validation. //GridWeb1.ForceValidation = true; string path = Server.MapPath("~"); path = path.Substring(0, path.LastIndexOf("\\")); string fileName = path + "\\File\\Input.xls"; // Imports from a excel file. GridWeb1.ImportExcelFile(fileName); GridWorksheetCollection sheets = GridWeb1.WorkSheets; // Sets cell validation. GridValidationCollection gridValidationCollection = sheets[0].Validations; // Regular expression. GridValidation C5 = gridValidationCollection.Add(); C5.AddACell("C5"); //C5.Operator = OperatorType.BETWEEN; C5.ValidationType = GridValidationType.CustomExpression; C5.RegEx = @"\d{6}"; // Number. GridValidation C6 = gridValidationCollection.Add(); C6.AddACell("C6"); C6.ValidationType = GridValidationType.Decimal; // Integer. GridValidation C7 = gridValidationCollection.Add(); C7.AddACell("C7"); C7.ValidationType = GridValidationType.WholeNumber; // Date. GridValidation C8 = gridValidationCollection.Add(); C8.AddACell("C8"); C8.ValidationType = GridValidationType.Date; // DateTime GridValidation C9 = gridValidationCollection.Add(); C9.AddACell("C9"); C9.ValidationType = GridValidationType.DateTime; // List. GridValidation C10 = gridValidationCollection.Add(); C10.AddACell("C10"); C10.ValidationType = GridValidationType.List; StringCollection value = new StringCollection(); value.Add("Fortran"); value.Add("Pascal"); value.Add("C++"); value.Add("Visual Basic"); value.Add("Java"); value.Add("C#"); C10.ValueList = value; value.Clear(); // DropDownList. GridValidation C11 = gridValidationCollection.Add(); C11.AddACell("C11"); C11.ValidationType = GridValidationType.DropDownList; value.Add("Bachelor"); value.Add("Master"); value.Add("Doctor"); C11.ValueList = value; // FreeList GridValidation C12 = gridValidationCollection.Add(); C12.AddACell("C12"); C12.ValidationType = GridValidationType.FreeList; value.Add("US"); value.Add("Britain"); value.Add("France"); C12.ValueList = value; // Custom function GridValidation C13 = gridValidationCollection.Add(); C13.AddACell("C13"); C13.ValidationType = GridValidationType.CustomFunction; C13.ClientValidationFunction = "myvalidation1"; // CheckBox GridValidation C14 = gridValidationCollection.Add(); C14.AddACell("C14"); C14.ValidationType = GridValidationType.CheckBox; }
protected void GridNoteView_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { GridValidation.ValidateLength("Text", 2, sender, e); GridValidation.ValidateLength("Title", 2, sender, e); }
private void InitData() { // Gets the web application's path. string path = Server.MapPath("~"); // Upper level. path = path.Substring(0, path.LastIndexOf("\\")); string fileName = path + "\\File\\Hyperlink.xls"; // Clears datasheets first. GridWeb1.WorkSheets.Clear(); // Imports from a excel file. GridWeb1.ImportExcelFile(fileName); GridHyperlinkCollection ghc = GridWeb1.WorkSheets[0].Hyperlinks; //Adds a text hyperlink that gos to Aspose site and opens in new window int i = ghc.Add("B1", "http://www.aspose.com"); GridHyperlink linkOfText1 = ghc[i]; linkOfText1.Target = "_blank"; linkOfText1.TextToDisplay = "Aspose site"; linkOfText1.ScreenTip = "Go to Aspose site and open in new window"; ////Adds a text hyperlink that gos to Aspose site and opens in current window GridHyperlink linkOfText2 = ghc[ghc.Add("B2", "http://localhost:40056/grid/common/Pagination.aspx")]; linkOfText2.TextToDisplay = "Paginatind sheet Demo"; linkOfText2.Target = "_self"; linkOfText2.ScreenTip = "Go to Aspose site and open in current window"; //Adds a text hyperlink that gos to Aspose site and opens in top window GridHyperlink linkOfText3 = ghc[ghc.Add("B3", "http://www.aspose.com/categories/.net-components/aspose.cells-for-.net/default.aspx")]; linkOfText3.TextToDisplay = "Aspose.Cells.GridWeb Product"; linkOfText3.Target = "_top"; linkOfText3.ScreenTip = "Go to Aspose site and open in top window"; //Adds a text hyperlink that gos to Aspose site and opens in parent window GridHyperlink linkOfText4 = ghc[ghc.Add("B4", "http://www.aspose.com/Community/Forums/258/ShowForum.aspx")]; linkOfText4.TextToDisplay = "Aspose.Cells.GridWeb Forums"; linkOfText4.Target = "_parent"; linkOfText4.ScreenTip = "Go to Aspose site and open in parent window"; //Adds a image hyperlink that gos to Aspose site and opens in current window GridHyperlink linkOfImage1 = ghc[ghc.Add("B6", "http://www.aspose.com")]; linkOfImage1.ImageURL = "../../Images/Aspose.Banner.gif"; linkOfImage1.Target = "_blank"; linkOfImage1.ScreenTip = "Go to Aspose site and open in new window"; //Adds a image hyperlink that gos to Aspose.Cells.GridWeb site and opens in new window GridHyperlink linkOfImage2 = ghc[ghc.Add("B7", "http://www.aspose.com/categories/.net-components/aspose.cells-for-.net/default.aspx")]; linkOfImage2.ImageURL = "../../Images/Aspose.Grid.gif"; linkOfImage1.Target = "_blank"; linkOfImage2.ScreenTip = "Go to Aspose site and open in new window"; //Adds a CellImage GridHyperlink image = ghc[ghc.Add("B8", "")]; image.ImageURL = "../../Images/Aspose.Grid.gif"; //image.ActionType = HyperlinkActionType.CellCommand; image.ScreenTip = "A simple CellImage."; GridWeb1.WorkSheets[0].Cells["A8"].PutValue("Creates a CellImage:"); GridWeb1.WorkSheets[0].Cells.SetRowHeight(7, 100); //Picture pi = GridWeb1.WebWorksheets[0].Pictures.AddPicture("B8"); //pi.Image = ""; GridCells cells = GridWeb1.WorkSheets[1].Cells; GridValidationCollection gvc = GridWeb1.WorkSheets[1].Validations; GridValidation validation = gvc.Add("B13"); validation.ValidationType = GridValidationType.DropDownList; StringCollection value = new StringCollection(); value.Add("1996"); value.Add("1997"); value.Add("1998"); validation.ValueList = value; cells["B13"].PutValue("1996"); //Adds a cell command hyperlink GridHyperlink linkOfCellCommand1 = ghc[ghc.Add("C13", "")]; linkOfCellCommand1.Command = "Year"; linkOfCellCommand1.ScreenTip = "Summarizes Sales by Year"; linkOfCellCommand1.ImageURL = "../../Images/button1.bmp"; GridValidation validationB14 = gvc.Add("B14"); validationB14.ValidationType = GridValidationType.DropDownList; validationB14.Formula1 = "1,2,3,4"; cells["B14"].PutValue("1"); //Adds a cell command hyperlink GridHyperlink linkOfCellCommand2 = ghc[ghc.Add("C14", "")]; linkOfCellCommand2.Command = "Quarter"; linkOfCellCommand2.ScreenTip = "Summarizes Sales by Quater"; linkOfCellCommand2.ImageURL = "../../Images/button2.bmp"; }
protected void GridCustomerEmailView_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { GridValidation.ValidateLength("Email", 2, sender, e); }