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

[Solved] Two control in CellEditTemplate

2 Answers 89 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
xiaofeng
Top achievements
Rank 1
xiaofeng asked on 18 Sep 2009, 11:15 AM
The is a column in which I set the  CellEditTemplate as below.
<telerikGridView:GridViewDataColumn.CellEditTemplate> 
                        <DataTemplate> 
                           <Grid> 
                              <Grid.ColumnDefinitions> 
                                 <ColumnDefinition Width="70*"/> 
                                 <ColumnDefinition Width="30*"/> 
                              </Grid.ColumnDefinitions> 
                              <Grid.RowDefinitions> 
                                 <RowDefinition Height="25" /> 
                              </Grid.RowDefinitions> 
                              <TextBox x:Name="txtOtherTag" Margin="0,0,0,0"  Grid.Column="0" Text="{Binding OtherTag, Mode=TwoWay}"/> 
                              <Common:IscButton x:Name="btnOtherTag"  Click="btnOtherTag_Click" Margin="0,0,0,0" Grid.Column="1" Content="..." ></Common:IscButton> 
                           </Grid> 
                        </DataTemplate> 
                     </telerikGridView:GridViewDataColumn.CellEditTemplate> 
                  </telerikGridView:GridViewDataColumn> 
I want to change the corresponding text of the "txtOthertag" when I click the btnOtherTag.Can you Give me a solution?Thank you.

2 Answers, 1 is accepted

Sort by
0
xiaofeng
Top achievements
Rank 1
answered on 21 Sep 2009, 12:53 AM
help,please
0
Accepted
Milan
Telerik team
answered on 22 Sep 2009, 09:05 AM
Hello xiaofeng,

You could do the following in the Click event handler:

// Required namespaces: System.Linq; Telerik.Windows.Controls;  
private void btnOtherTag_Click(object sender, RoutedEventArgs e)  
{  
    FrameworkElement element = sender as FrameworkElement;  
      
    var box =   
        element  
        .ParentOfType<GridViewCell>()  
        .ChildrenOfType<TextBox>()  
        .Where((textBox) => textBox.Name == "txtOtherTag")  
        .FirstOrDefault();  
 
    if (box != null)  
        box.Text = "Default Text";  


All the best,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
xiaofeng
Top achievements
Rank 1
Answers by
xiaofeng
Top achievements
Rank 1
Milan
Telerik team
Share this question
or