Setting up a template column to show true false

Answered (Verified) This post has 1 verified answer and 4 replies

Not Ranked
Posts: 11
whocares Posted: Fri Mar 5, 2010 @ 4:31 AM
I have various stored procedures which return data to the grid with zero or a one. In some cases I want to set the visible values to true/false and some to yes/no (and possibly others). Rather than change all the stored procedures I would like to do this with a template, but am unsure of how to change the text of a textblock based on the binding result.

Any help would be much appreciated.

Answered (Verified) Verified Answer

Top 10 Contributor
Posts: 1,302
Answered (Verified) milos Posted: Fri Mar 5, 2010 @ 6:03 AM
Verified by whocares

whocares, it sounds like you need to use a value converter. You can use this approach to shape the column data in any way you want, as it is bound. There is some good documentation about it on MSDN.

 

I hope this helps.

 

All Replies

Top 10 Contributor
Posts: 1,302
Answered (Verified) milos Posted: Fri Mar 5, 2010 @ 6:03 AM
Verified by whocares

whocares, it sounds like you need to use a value converter. You can use this approach to shape the column data in any way you want, as it is bound. There is some good documentation about it on MSDN.

 

I hope this helps.

 

Top 500 Contributor
Posts: 24
lakshmi28 Posted: Tue Apr 27, 2010 @ 3:25 AM
Hi Milos,
Top 500 Contributor
Posts: 24
lakshmi28 Posted: Tue Apr 27, 2010 @ 3:30 AM
Hi Milos,
             In my datagrid template column i have one label and one textbox i want to assign lable background color dynamically in row loaded event. how to get these two controls instance in Row loaded event?

<

 

cart:DataGridTemplateColumn Header="Answer" Width="300" Binding="{Binding}">

 

 

<cart:DataGridTemplateColumn.CellTemplate>

 

 

<DataTemplate>

 

 

<StackPanel Orientation="Horizontal">

 

 

<dataInput:Label x:Name="lbl_color" Content="   " Height="13" VerticalContentAlignment="Center" ></dataInput:Label>

 

 

<TextBlock Text="{Binding ans}" VerticalAlignment="Center"></TextBlock>

 

 

</StackPanel>

 

 

</DataTemplate>

 

 

</cart:DataGridTemplateColumn.CellTemplate>

 

 

</cart:DataGridTemplateColumn>

Top 10 Contributor
Posts: 1,302
milos Posted: Wed Apr 28, 2010 @ 12:16 PM

It sounds like what you are looking for is DataGridCell's Content property. You can get the cell from the row (Cells collection).

 

I hope this helps.

 

Page 1 of 1 (5 items)