protected void saveButton_Click1(object sender, EventArgs e) { string intCheck = saveCategoryNameTextBox.Text; int count = 0, z = 0; for (int i = 0; i < intCheck.Length; i++) { if ((intCheck[i] >= '0' && intCheck[i] <= '9')) { count++; } if ((intCheck[i] >= 'a' && intCheck[i] <= 'z') || (intCheck[i] >= 'A' && intCheck[i] <= 'Z')) { z++; } } if (count > 0 || z == 0) { outputLabel.Text = "Number (0-9) and special characters (@,#,$..) are not allowed! "; saveCategoryNameTextBox.Text = ""; } else { ProductCategory productCategory = new ProductCategory(); productCategory.CategoryName = saveCategoryNameTextBox.Text; outputLabel.Text = productCategoryManager.Save(productCategory); saveCategoryNameTextBox.Text = ""; productCategoryGridView.DataSource = productCategoryManager.GetAllProductCategory(); productCategoryGridView.DataBind(); } }