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

Bind value from CellEditTemplate to GridView

5 Answers 99 Views
GridView
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 16 Feb 2011, 08:41 AM
What's the correct binding to associate a value in a custom control in a CellEditTemplate with the value shown in the grid?  For example with this grid:

<telerik:RadGridView >
   <telerik:RadGridView.Columns>
    <telerik:GridViewMaskedTextBoxColumn Header="Test">
     <telerik:GridViewMaskedTextBoxColumn.CellEditTemplate>
      <DataTemplate>
                            <telerik:RadMaskedTextBox/>
                        </DataTemplate>
     </telerik:GridViewMaskedTextBoxColumn.CellEditTemplate>
    </telerik:GridViewMaskedTextBoxColumn>
   </telerik:RadGridView.Columns>
  </telerik:RadGridView>

I'm having an issue where values entered into the RadMaskedTextBox don't show up in the grid when editing is finished.  Also, any value present in the grid doesn't automatically show up in the RadMaskedTextBox when editing begins.  What's the proper way to associate the grid value with the custom control value?

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 16 Feb 2011, 08:46 AM
Hi,

 Generally you do not need to declare CellTemplate for GridViewMaskedTextBoxColumn - just assign binding (DataMemeverBinding) for this column. You can check our demo for more info - for example this one:
http://demos.telerik.com/silverlight/#GridView/ColumnTypes

Regards,
Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
James
Top achievements
Rank 1
answered on 16 Feb 2011, 04:32 PM
If you look through my previous posts you can see why I'm using a CellEditTemplate.  In fact, I initially asked this question as part of a longer thread that contains the explanation, but since I received no response I decided to make a new thread.

Could you please answer the question?
0
Vlad
Telerik team
answered on 16 Feb 2011, 04:35 PM
Hello,

 The situation is the same with CellEditTemplate. Can you clarify why you've not set DataMemeverBindingfor this column?

Best wishes,
Vlad
the Telerik team
0
James
Top achievements
Rank 1
answered on 17 Feb 2011, 04:06 AM
Thanks Vlad - I updated my markup as follows:

<telerik:RadGridView x:Name="uxGrid" AutoGenerateColumns="False">
   <telerik:RadGridView.Columns>
    <telerik:GridViewMaskedTextBoxColumn MaskType="None" Header="Test" DataMemberBinding="{Binding Test}">
     <telerik:GridViewMaskedTextBoxColumn.CellEditTemplate>
      <DataTemplate>
                            <telerik:RadMaskedTextBox MaskedText="{Binding Test}"/>
                        </DataTemplate>
     </telerik:GridViewMaskedTextBoxColumn.CellEditTemplate>
    </telerik:GridViewMaskedTextBoxColumn>
   </telerik:RadGridView.Columns>
  </telerik:RadGridView>

With this UI I get half of the solution - the RadMaskedTextBox will pick up the value from the grid when editing starts.  However, if I type something into the control and move to the next cell of the grid that new value is then lost.  Is something wrong with that binding?
0
Jose
Top achievements
Rank 1
answered on 17 Apr 2012, 07:25 PM
Please answer this. I have the same problem.
Tags
GridView
Asked by
James
Top achievements
Rank 1
Answers by
Vlad
Telerik team
James
Top achievements
Rank 1
Jose
Top achievements
Rank 1
Share this question
or