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

[Solved] Fields with errors with red borders

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bastian
Top achievements
Rank 1
Bastian asked on 02 Apr 2013, 08:54 AM
Hi!

I have fowlling insert command

   void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
        {
........
 var result = blala.ValidateAndSave(...);
 
 if (result.ResultCode == ValidationResultCode.Ok)
                {
                    AddMessage("The data were successfully validated and Saved!");
                    NewAllEntriesToAccount();
                }
                else
                {
                    AddMessage("Please check the data. The following errors were found: ");
                            AddErrorList(RadGrid1.Columns[meldung.SpaltenIndex].UniqueName);
                }

If the valditaion with errors, i want to change the border color of the field in the Grid Editor red. In which fields the errors are known to me.
I have tried to do this in the RadGrid1_ItemCreated event, but the event fires before the InsetCommand:

GridEditableItem item = (GridEditableItem)e.Item;
                      TextBox combo = (TextBox)item[itemm.ItemArray[0].ToString().Replace(" ", "")].Controls[0];
                      combo.BackColor = GetColor((ClArt)itemm.ItemArray[2]);
 
                      if (IsInErrorList(itemm.ItemArray[0].ToString().Replace(" ", "")))
                      {
                          combo.BorderStyle = BorderStyle.Solid;
                          combo.BorderWidth = 2;
                          combo.BorderColor = System.Drawing.Color.Red;
                      }


Have anyone a idea, how i can do this ?

Thank you very much

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 05 Apr 2013, 07:57 AM
Hello Bastian,

You can try to execute your custom logic on ItemDataBound event which is handled on a later stage of the page life cycle:
http://www.telerik.com/help/aspnet-ajax/grid-distinguish-differences-between-itemcreated-itemdatabound.html

Hope this helps.

Kind regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Bastian
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or