Can anyone suggest how to use Required field validators for a datagrid while
edit/update operations? For e.g. to prevent the user from updating a column
with a blank. I have tried doing something but it doesn't work. The code is
here below and you might suggest if I am doing anything wrong in this.
private void dgUser_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
TextBox[] t = new TextBox[3];
t[0] = (TextBox)(e.Item.Cells[1].Controls[0]);
Rfv = new RequiredFieldValidator();
Rfv.ControlToValidate = t[0].ID;
Rfv.Enabled = true;
Rfv.ErrorMessage = "Fields Cannot be Blank";
Rfv.Display = ValidatorDisplay.None;
t[0].Controls.Add(Rfv);
}
Also I would like to know if I can put a limit on the maximum no. of
characters on the controls.