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

filter textbox findcontrol returns null

3 Answers 153 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Soumya
Top achievements
Rank 1
Soumya asked on 24 Jul 2012, 12:12 PM
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....


3 Answers, 1 is accepted

Sort by
0
Soumya
Top achievements
Rank 1
answered on 25 Jul 2012, 04:58 AM
Any answer?
0
Shinu
Top achievements
Rank 2
answered on 25 Jul 2012, 09:10 AM
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.
0
Soumya
Top achievements
Rank 1
answered on 25 Jul 2012, 10:26 AM
Thanks Shinu.
Tags
Filter
Asked by
Soumya
Top achievements
Rank 1
Answers by
Soumya
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or