I have a Silverlight DataGrid control inside which I have a textbox and a button control.
It is as under
<dg:DataGrid x:Name="myGrid" AutoGenerateColumns="False">
<dg:DataGrid.Columns>
<dg:DataGridTemplateColumn Header="Name" Width="100">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Name}" x:name="txtName"/>
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn Header="Age" Width="100">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Age}" x:name="txtAge"/>
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn Header="Action" Width="100">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button x:Name="btnCilck" Content="Click" Click="btnClick_Click />
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
</dg:DataGrid.Columns>
</dg:DataGrid>
What I want to do is that at runtime I want to fetch the textbox value (txtName) for the row selected.
I mean, say the grid has 10 rows(i.e. 10 textbox's in that particular column; say Column Name) and 10 Buttons in say Action column(let's name it like that).
Now when I click on the 5th rows Click button, I want to get the value from the textbox present in that row.
Thanks in advance.