Radgrid not finding range validator

3 posts, 1 answers
  1. John Aghadiuno
    John Aghadiuno avatar
    9 posts
    Member since:
    Apr 2011

    Posted 12 Dec 2011 Link to this post

    Hello all. Been trying to solve a problem to no avail. Have tried everything I can. Basically trying to set the minimun and maximum values of a range validator residing inside RadGrid. But it's not working.

    Here is my code.

        <telerik:GridTemplateColumn DataField="claim_date" DataType="System.DateTime"
            FooterText="Totals: " HeaderText="Date" SortExpression="claim_date"
            UniqueName="claim_date">
     
     
            <ItemTemplate>
                <asp:Label ID="claim_dateLabel" runat="server"
                    Text='<%# Eval("claim_date", "{0:MM/dd/yyyy}") %>'></asp:Label>
                     
            </ItemTemplate>
     
             
            <EditItemTemplate>
                            <telerik:RadDatePicker ID="claim_dateTextBox" runat="server" DBSelectedDate='<%# Bind("claim_date") %>' Width="100" />
                                                               
                 <asp:RequiredFieldValidator ID="fvDateRequiredFieldValidator" runat="server" ErrorMessage="Claim date is required" ControlToValidate="claim_dateTextBox" ValidationGroup="DataEntryChk" Display="Dynamic" Font-Bold="true"  />                                       
                 
    <asp:RangeValidator ID="fvDateValidator" Type="Date" ControlToValidate="claim_dateTextBox" runat="server" ErrorMessage="Cannot save claim item. Please select/enter a date in the same month as the voucher month." SetFocusOnError="True" ValidationGroup="DataEntryChk" Display="Dynamic" Font-Bold="true"  />  
     
            </EditItemTemplate>
     
            
        </telerik:GridTemplateColumn>


    And in code behind I have the following.

    Protected Sub ClaimsGV_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles ClaimsGV.ItemCommand
     
     
        If e.CommandName = RadGrid.UpdateCommandName Or e.CommandName = RadGrid.PerformInsertCommandName Or e.CommandName = RadGrid.EditCommandName Then
     
     
            Dim editform As GridEditFormItem = DirectCast(DirectCast(e.Item, Telerik.Web.UI.GridDataItem).EditFormItem, GridEditFormItem)
            'Dim editform As GridEditableItem = CType(e.Item, GridEditableItem)
     
     
            Dim fvDateValidator As RangeValidator = CType(editform.FindControl("fvDateValidator"), RangeValidator)
     
     
            If fvDateValidator IsNot Nothing And iMaxEndDate <> "" And iMinStartDate <> "" Then
                fvDateValidator.Enabled = True
                fvDateValidator.Visible = True
                fvDateValidator.MinimumValue = iMinStartDate.ToShortDateString
                fvDateValidator.MaximumValue = iMaxEndDate.Date.ToShortDateString
            End If
     
     
        End If
     
     
    End Sub

  2. Answer
    Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 12 Dec 2011 Link to this post

    Hello,

    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
            {
                 
                 
     
                if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                {
                    GridEditableItem item = e.Item as GridEditableItem;
     
                    // access or set control's property here
                    RadDatePicker claim_dateTextBox = item.FindControl("claim_dateTextBox") as RadDatePicker;
                    RequiredFieldValidator fvDateRequiredFieldValidator = item.FindControl("fvDateRequiredFieldValidator") as RequiredFieldValidator;
                }
            }


    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. John Aghadiuno
    John Aghadiuno avatar
    9 posts
    Member since:
    Apr 2011

    Posted 12 Dec 2011 Link to this post

    Thank you. That works!
Back to Top