how to define validationGroup for GridEditCommandColumn ?

3 posts, 0 answers
  1. dank
    dank avatar
    12 posts
    Member since:
    Apr 2009

    Posted 29 Apr 2010 Link to this post

    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. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 29 Apr 2010 Link to this post

    This demo should be of help to you.


    You need to set the ValidationSettings of the RadGrid.

    I hope that helps.


  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. dank
    dank avatar
    12 posts
    Member since:
    Apr 2009

    Posted 29 Apr 2010 Link to this post


    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..

Back to Top