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

plz help me out

4 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Arsalan
Top achievements
Rank 1
Arsalan asked on 20 Jan 2012, 10:18 AM
I have been stuck with this problem for last couple of days , i have a rad grid it has a master table and a detail table ,there is a custom edit /insert form in the detail table , all the data entries in the detail table will occur through this form the form has some controls and a rad upload control , i have to implement required field validation on the rad upload control which is in the form tempelate , i have read the articles on your site explaining the use of custom validators to achieve the task , but here is the rub , when on server validation event i traverse through the grid it is returning all rows of the detail table but it is not returning the grid edit form item , as i have mentioned the rad upload is in the form item

here is the code that i have used on server validation event

    protected void Validatecustom(object source, ServerValidateEventArgs e)
        {
            e.IsValid = true;
           // List<GridDataItem> obj = rgridPersonalAssistant.MasterTableView.DetailTables[0].Items;


            
            foreach (GridDataItem masterrow in rgridPersonalAssistant.MasterTableView.Items)
            {
                List<GridTableView> cb = masterrow.ChildItem.NestedTableViews.Cast<GridTableView>().ToList();
                //rgridPersonalAssistant.e
                
                 
                //views[0].items
               
                foreach (var c in masterrow.ChildItem.NestedTableViews[0].Items)
                {

                    if (c is GridDataItem)
                    {
                        GridDataItem cc = c as GridDataItem;
                    }
                    if (c is GridEditFormItem)
                    {
                       // GridEditFormItem obj = c as GridEditFormItem;
                        GridEditableItem obj = c as GridEditableItem;
                       
                        foreach(TableCell cll in obj.Cells)
                        {
                            string s = cll.Text;
                        }
                        RadUpload objupload = (RadUpload)obj.FindControl("rfScannedDocument");
                        if (objupload != null)
                        {
                            int b = objupload.UploadedFiles.Count;
                            if (b == 0)
                            {
                                e.IsValid = false;
                            }

                        }



                    }


                }
            }

            




                   

4 Answers, 1 is accepted

Sort by
0
Arsalan
Top achievements
Rank 1
answered on 21 Jan 2012, 10:42 PM
telerik help me out plz, we are racing against deadline here , i have to dispatch it for testing , plz help me or at-least hint me about how to get out of this bind
0
Jayesh Goyani
Top achievements
Rank 2
answered on 22 Jan 2012, 01:19 AM
Hello Arsalan,

you can get edit items using below code
foreach (GridEditableItem item in RadGrid1.EditItems)
           {
 
           }

Thanks,
Jayesh Goyani
0
Accepted
Adeel
Top achievements
Rank 1
answered on 23 Jan 2012, 10:42 AM
Add Custom validator control in your page and use server side validation

protected void Validatecustom(object source, ServerValidateEventArgs e)
        {
         
            CustomValidator CustomValidator1 = (CustomValidator)source;


            GridEditFormItem dataitem = (GridEditFormItem)CustomValidator1.NamingContainer;
            RadUpload rfScanDocUpload = (RadUpload)dataitem.FindControl("rfScannedDocument");


            if (rfScanDocUpload.UploadedFiles.Count > 0 && rfScanDocUpload.InvalidFiles.Count == 0)
                e.IsValid = true;
            else
                e.IsValid = false;


        }
0
Arsalan
Top achievements
Rank 1
answered on 23 Jan 2012, 01:51 PM
thanks adeel , you are a life saver , your trick worked like a charm , thanks for the help ,i am genuinely grateful !!!
Tags
Grid
Asked by
Arsalan
Top achievements
Rank 1
Answers by
Arsalan
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Adeel
Top achievements
Rank 1
Share this question
or