filter textbox findcontrol returns null

4 posts, 0 answers
  1. Soumya
    Soumya avatar
    108 posts
    Member since:
    Jul 2012

    Posted 24 Jul 2012 Link to this post

    I have a name column in my grid.
    I am trying to get the value in the filter textbox for the name column.

    <telerik:GridBoundColumn HeaderText="Patient Name" UniqueName="pt_name" DataField="pt_name" >
                   <FilterTemplate>
                       <telerik:RadTextBox ID="RTName" runat="server" Width="200px" ClientEvents-OnValueChanged="ValueChanged" ></telerik:RadTextBox>
                           <telerik:RadScriptBlock ID="RBName" runat="server">
     
                                   <script type="text/javascript">
                                       function ValueChanged(sender, args) {
                                           var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                           var Name = $find('<%# ((GridItem)Container).FindControl("RTName").ClientID %>');
     
                                           tableView.filter("pt_name", Name, "StartsWith");
                                       }                                  
                                   </script>
     
                               </telerik:RadScriptBlock>
                        
                   </FilterTemplate>
                  </telerik:GridBoundColumn>

    aspx.cs
    if (e.CommandName == RadGrid.FilterCommandName)
                {
                    Pair filterPair = (Pair)e.CommandArgument;
                    switch (filterPair.Second.ToString())
                    {
                        case "pt_Date":
                            {
                               //
                            }
                        case ("pt_name"):
                            {
                                 
                                TextBox searchName = (e.Item as GridFilteringItem)[filterPair.Second.ToString()].FindControl("RTName") as TextBox;
                               search = searchName.Text + "%";
                                break;
                            }
     
                    }
                }

    But I am not getting the textbox control in the program. Value of 'searchName' is Null.
    Please help me on this....


  2. Soumya
    Soumya avatar
    108 posts
    Member since:
    Jul 2012

    Posted 24 Jul 2012 Link to this post

    Any answer?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Jul 2012 Link to this post

    Hello Soumya,

    Try accessing it as RadTextBox as shown below.
    C#:
    case ("pt_name"):
     {
      RadTextBox searchName = (e.Item as GridFilteringItem)[filterPair.Second.ToString()].FindControl("RTName") as RadTextBox;
         . . .
    }

    Thanks,
    Shinu.
  5. Soumya
    Soumya avatar
    108 posts
    Member since:
    Jul 2012

    Posted 25 Jul 2012 Link to this post

    Thanks Shinu.
Back to Top