protected void grvCustomers_OnRowUpdating(object sender, GridViewUpdateEventArgs e)
{
var row = grvCustomers.Rows[e.RowIndex];
var customerListIndex = row.DataItemIndex;
var customerid = (int) grvCustomers.DataKeys[customerListIndex].Value;
var newName = ((TextBox) row.Cells[1].Controls[0]).Text; //0 = id, 1 = Phonenumber, 2 = Name
var newPhonenr = ((TextBox) row.Cells[2].Controls[0]).Text;
if (newPhonenr.Length == 12)
{
_c.UpdateCustomer(customerid, newName, newPhonenr);
grvCustomers.EditIndex = -1;
grvCustomers.DataSource = _c.GetAllCustomers();
grvCustomers.DataBind();
}
else
{
errormessage2.Text = "Fill in a correct phone number!";
errormessage2.Visible = true;
}
}
Hi guys, how can I check whether or not my newName
contains a digit? I have used Regex.IsMatch()
but I am trying to allow spaces as well in names such like John Doe or Christopher Philips. Basically, I'm trying to allow names with spaces but at the same time check if it's only a string. And I really don't one typing like X Æ A-12 Musk.