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

how to define validationGroup for GridEditCommandColumn ?

2 Answers 267 Views
Grid
This is a migrated thread and some comments may be shown as answers.
dank
Top achievements
Rank 1
dank asked on 29 Apr 2010, 01:48 PM
hi all ,i'm devoloping a multi image uploader inside radgrid  component
I used GridEditCommandColumn  as opening edit block
this grid also inside a page which have validators

so How to define a validation group for edit mode of grid control?


 <telerik:RadGrid runat="server" ID="ImagesRadGrid" AllowPaging="True" AllowSorting="True" 
          OnNeedDataSource="ImagesRadGrid_NeedDataSource" AutoGenerateColumns="False" Width="97%"    
          OnUpdateCommand="ImagesRadGrid_UpdateCommand" OnPreRender="ImagesRadGrid_PreRender" 
            ShowStatusBar="True" OnInsertCommand="ImagesRadGrid_InsertCommand" OnDeleteCommand="ImagesRadGrid_DeleteCommand" 
            GridLines="None" OnItemDataBound="RadGrid1_ItemDataBound" OnItemCreated="RadGrid1_ItemCreated" PageSize="2">  
            <PagerStyle Mode="NumericPages" AlwaysVisible="true" /> 
            <MasterTableView Width="100%" DataKeyNames="ImageUrl" > 
                <Columns> 
                    <telerik:GridEditCommandColumn ButtonType="ImageButton"   > 
                        <HeaderStyle Width="3%" /> 
                    </telerik:GridEditCommandColumn> 
                    <telerik:GridTemplateColumn HeaderText="Culture" UniqueName="Culture" SortExpression="Culture">  
                        <ItemTemplate> 
                            <asp:Label runat="server" ID="lblCulture" Text='<%# Eval("Culture.Description") %>' /> 
                        </ItemTemplate> 
                        <EditItemTemplate> 
                        <asp:Label runat="server" ID="lblCulture" Text='<%# Bind("Culture.Description") %>' /> 
                        </EditItemTemplate> 
                        <HeaderStyle Width="30%" /> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridTemplateColumn UniqueName="Upload">  
                    <ItemTemplate> 
                    <img name='imageViewer' alt="image" width='100' height='100'   src='<%# "../ImageWebForm.aspx?ImagePath="+Eval("ImageUrl") %>' /> 
                    </ItemTemplate> 
                    <EditItemTemplate > 
                    <div id="fileUpladerDiv">  
                        <table style="width:300px">  
                        <tr> 
                    <td style="width:250px;" >          
                        <telerik:RadUpload ID="RadUpload1"  runat="server"   InitialFileInputsCount="1"   
                        AllowedFileExtensions=".png" ControlObjectsVisibility="None"  Width="222px" Skin="WebBlue"  /> 
                    </td> 
                    </tr> 
                    </table> 
                    </div> 
                    </EditItemTemplate> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton">  
                        <HeaderStyle Width="2%" /> 
                    </telerik:GridButtonColumn> 
                </Columns> 
                <EditFormSettings> 
                    <EditColumn ButtonType="ImageButton" /> 
                </EditFormSettings> 
            </MasterTableView>   
        </telerik:RadGrid>  

2 Answers, 1 is accepted

Sort by
0
robertw102
Top achievements
Rank 1
answered on 29 Apr 2010, 02:07 PM
This demo should be of help to you.


You need to set the ValidationSettings of the RadGrid.

I hope that helps.


0
dank
Top achievements
Rank 1
answered on 29 Apr 2010, 03:19 PM

Thnx for your reply
I tried the demo as
put ValidationGroup="imageEditorValGroup" for radgrid

<ValidationSettings ValidationGroup="imageEditorValGroup" EnableValidation="true" CommandsToValidate="PerformInsert,Update" />

and an other point at code behind i bind a custom validator as

 protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
        {  
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
            {  
                RadUpload editorRadUpload = ((GridEditableItem)e.Item).EditManager.GetColumnEditor("Upload").ContainerControl.FindControl("RadUpload1") as RadUpload;  
                TableCell cell = (TableCell)editorRadUpload.Parent;  
                CustomValidator validator = new CustomValidator();  
                validator.ErrorMessage = "Please select file to be uploaded";  
                validator.ClientValidationFunction = "validateRadUpload";  
               // validator.ValidationGroup = "imageEditorValGroup";  
                validator.Display = ValidatorDisplay.Dynamic;  
                cell.Controls.Add(validator);  
            }  
        } 

any button clicked on the page that contains usercontrol which includes the radgrid  is not go to validate function
but also inside grid any validate function fired...
so i found a way like this
i gived validationgroup for the controls outside grid this accomplished what i want ,for now..

Tags
Grid
Asked by
dank
Top achievements
Rank 1
Answers by
robertw102
Top achievements
Rank 1
dank
Top achievements
Rank 1
Share this question
or