This is a migrated thread and some comments may be shown as answers.

Validation - if txtbx1 = null, then txtbx2 = non-editable in pop-up edit form

1 Answer 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 23 Feb 2013, 05:56 AM
Hi Telerik,
I have RADgird with columns startDate, endDate,  statusLevel with editmode="popup".
If i select EDIT, i need to do the following validation
1. If startDate = null, then endDate & statusLevel must be non-editable
2. if endDate = not null, then startDate cannot be null & statusLevel = 100

please i need the help urgently

Thanks in advance
Alex


1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Feb 2013, 04:54 AM
Hi,

You can add a RequiredFieldValidator in edit mode as shown below.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
        if ((e.Item is GridEditFormItem && e.Item.IsInEditMode))
        {
           GridEditFormItem item = (GridEditFormItem)e.Item;
            if (item["UniqueName"].Text == "")
            {
                TextBox txt = (TextBox)item["UniqueName"].Controls[0];
                txt.ReadOnly = true;
            }
            if (item["GridDateTimeColumnEndDate"].Text =="8/12/2013")
            {
                item["OrderID"].Text = "100";
                GridTextBoxColumnEditor editor = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor("UniqueName");
                TableCell cell = (TableCell)editor.TextBoxControl.Parent;
                RequiredFieldValidator validator = new RequiredFieldValidator();
                editor.TextBoxControl.ID = "ID_for_validation";
                validator.ControlToValidate = editor.TextBoxControl.ID;
                validator.ErrorMessage = "*";
               cell.Controls.Add(validator);
            }
        }
}

Thanks,
Shinu
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or