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

GridViewDataColumn Binding not working

2 Answers 425 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 16 Oct 2014, 02:24 AM
I have the following RadGridView defined:                    

<telerik:RadGridView Grid.Row="1" x:Name="gvUnits" ItemsSource="{Binding UnitsOfMeasure}" ColumnWidth="*" 
                                         AutoGenerateColumns="False"
                                         RowEditEnded="Entity_EditEnded"
                                         Deleted="Entity_Deleted"
                                         Margin="5">
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" IsReadOnly="False"/>
                        </telerik:RadGridView.Columns>
                    </telerik:RadGridView>

From what I've read there should be a default cell edit template, but when I click on an item I only get a blank box. I have also tried adding a custom celledittmplate as follows:

                    <telerik:RadGridView Grid.Row="1" x:Name="gvUnits" ItemsSource="{Binding UnitsOfMeasure, Mode=TwoWay}" ColumnWidth="*" 
                                         AutoGenerateColumns="False"
                                         RowEditEnded="Entity_EditEnded"
                                         Deleted="Entity_Deleted"
                                         Margin="5">
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" IsReadOnly="False">
                                <telerik:GridViewDataColumn.CellEditTemplate>
                                    <DataTemplate>
                                        <TextBox Text="{Binding Name}"/>
                                    </DataTemplate>
                                </telerik:GridViewDataColumn.CellEditTemplate>
                            </telerik:GridViewDataColumn>
                        </telerik:RadGridView.Columns>
                    </telerik:RadGridView>
 Is there something else I need to do to make the text editable? Is it one-way binding by default?

I'm sure this is an easy question, I'm just new to your controls.

2 Answers, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 16 Oct 2014, 07:54 AM
Hello Eric,

I am not entirely sure what kind of data you have bound to your column. That is why I attached a sample project that demonstrates a common scenario with RadGridView. In general if you have a string property bound to the GridViewDataColumn, by default you will have a TextBox as an editor (CellEditTemplate) and a TextBlock as a CellTemplate. So by double clicking on a cell in that column, you will enter edit mode state (the default TextBox) for that cell.

For more information about RadGridView you can refer to our documentation, online demos and sdk examples:
1) Getting Started documentation article.
2) Online Demos.
3) SDK Examples - Although GitHub is a very well-known platform we saw a better and easier approach for reviewing our examples by developing our SDK Samples Browser


I hope this helps.

Regards,
Boris Penev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Eric
Top achievements
Rank 1
answered on 16 Oct 2014, 09:23 PM
Your example was very helpful, thank you. 

I was missing a few references.
Tags
GridView
Asked by
Eric
Top achievements
Rank 1
Answers by
Boris
Telerik team
Eric
Top achievements
Rank 1
Share this question
or