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

Required Field Validator for Upload in grid

3 Answers 129 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 11 Feb 2010, 05:41 PM

The telerik grid example:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/raduploadinajaxifiedgrid/defaultcs.aspx?product=upload

has the following:

        protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
        {  
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
            {  
                GridBinaryImageColumnEditor editor = ((GridEditableItem)e.Item).EditManager.GetColumnEditor("Upload") as GridBinaryImageColumnEditor;  
                TableCell cell = (TableCell)editor.RadUploadControl.Parent;  
                CustomValidator validator = new CustomValidator();  
                validator.ErrorMessage = "Please select file to be uploaded";  
                validator.ClientValidationFunction = "validateRadUpload";  
                validator.Display = ValidatorDisplay.Dynamic;  
                cell.Controls.Add(validator);  
            }  
        }  
 
but it is using a specific column type.
how do I add a required field validator to the upload if I am doing this:
                                        <telerik:gridtemplatecolumn uniquename="Upload" HeaderText="File Name">  
                                            <itemtemplate> 
                                                <asp:HyperLink ID="hlFile" runat="server" Target="_blank" /> 
                                            </itemtemplate> 
                                            <edititemtemplate> 
                                                <telerik:radupload id="RadUpload1" runat="server" ControlObjectsVisibility="None" InitialFileInputsCount="1" /> 
                                            </edititemtemplate> 
                                        </telerik:gridtemplatecolumn> 
 

I noticed this example:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/gridattachmentcolumn/defaultcs.aspx
what about validation on the attachment column?

3 Answers, 1 is accepted

Sort by
0
robertw102
Top achievements
Rank 1
answered on 12 Feb 2010, 08:06 PM
Just add the CustomValidator control to the EditItemTemplate.
0
Jim
Top achievements
Rank 1
answered on 12 Feb 2010, 08:51 PM
I don't think that will work. I tried adding a required validator to the edit item template, and it throws an error. The solution is not that simple unless you use a generic ASP.Net file upload. Probably because of the telerik controls ability to upload multiple files.
0
robertw102
Top achievements
Rank 1
answered on 12 Feb 2010, 09:31 PM
Are you adding a RequiredFieldValidator control or a CustomValidator control? I don't think a RequiredFieldValidator control will work on RadUpload. I always use CustomValidator controls on RadUpload and I create a client-side javascript check to make sure it contains a file to upload.
Tags
Upload (Obsolete)
Asked by
Jim
Top achievements
Rank 1
Answers by
robertw102
Top achievements
Rank 1
Jim
Top achievements
Rank 1
Share this question
or