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

GridView RowDetails binding issue

10 Answers 353 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Li
Top achievements
Rank 1
Li asked on 21 Oct 2010, 04:28 PM
Hi,

I'm trying to show rowdetails when rowSelected. 'mean' is one of column in DataTable, but I got  binding error. Can someone tell me what went wrong. Thanks.

System.Windows.Data Error: 40 : BindingExpression path error: 'mean' property not found on 'object' ''DataRow' (HashCode=22373539)'. BindingExpression:Path=mean; DataItem='DataRow' (HashCode=22373539); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')



<

 

 

telerikGrid:RadGridView x:Name="radGridView" Grid.Row="0" ItemsSource="{Binding DataTable}" AutoGenerateColumns="True"

 

 

 

ShowGroupPanel="False" RowDetailsVisibilityMode="VisibleWhenSelected" IsReadOnly="True"

 

 

 

AutoGeneratingColumn="radGridView_AutoGeneratingColumn"

 

 

 

RowIndicatorVisibility="Collapsed" IsSynchronizedWithCurrentItem="False">

 

 

 

 

<telerikGrid:RadGridView.RowDetailsTemplate>

 

 

 

 

<DataTemplate>

 

 

 

 

<StackPanel Orientation="Horizontal"

 

 

 

Margin="10,10,10,10">

 

 

 

 

<TextBlock Text="Average Measure Value: " />

 

 

 

 

<TextBlock Text="{Binding mean}" />

 

 

 

 

</StackPanel>

 

 

 

 

</DataTemplate>

 

 

 

 

</telerikGrid:RadGridView.RowDetailsTemplate>

 

 

 

 

</telerikGrid:RadGridView>

 

10 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 21 Oct 2010, 04:32 PM
Hi Li,

 Please use square brackets for the Binding with DataTable, DataView, etc. 

All the best,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Li
Top achievements
Rank 1
answered on 21 Oct 2010, 04:45 PM
Could you give me code example how you use square brackets in binding?

Thanks, I got it.
0
Leo
Top achievements
Rank 2
answered on 21 Oct 2010, 08:49 PM

Try binding it behind the code, sample square bracket binding. Hope it helps!
[Browsable(false)]
        public BindingContext BindingContext
        {
            get
            {
                if (bindingContext == null)
                {
                    bindingContext = new BindingContext();
                }
                return bindingContext;
  
            }
            set
            {
                bindingContext = value;
            }
        }
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public ControlBindingsCollection DataBindings
        {
            get
            {
                if (dataBindings == null)
                {
                    dataBindings = new ControlBindingsCollection(this);
                }
                return dataBindings;
            }
        }
0
Vlad
Telerik team
answered on 22 Oct 2010, 07:22 AM
Hi,

 You can find more info here:
http://msdn.microsoft.com/en-us/library/cc189022(VS.95).aspx
http://msdn.microsoft.com/en-us/library/cc645024(v=VS.95).aspx

Sincerely yours,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Julien
Top achievements
Rank 1
answered on 07 Jan 2011, 04:36 PM
Hi,

Is there a better way to handle this issue in the current version?  I am trying to edit cells (DataTable is underlying binding) but I am getting the same error as described earlier in this thread.  I create my columns in code and instantiate a Binding object such as Binding b = new Binding("columnName");

If I update my code to Binding b = new Binding("[columnName]"), the exception goes away.  However, other parts of the grid fail such as grouping since my column names in the DataTable do actually do not have brackets (and they should not). 

Perhaps I am not applying the suggestion of this thread correctly.

Could you please help?

Thanks,
Julien
0
Vlad
Telerik team
answered on 10 Jan 2011, 04:33 PM
Hello,

 You will not have problems with grouping with such binding. I've attached an example project for reference. 

Greetings,
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
Julien
Top achievements
Rank 1
answered on 10 Jan 2011, 06:08 PM
Thanks for reply but your sample project defines the columns in xaml.  I have to create the binding in code since columns are determined at runtime.  How would you do it?
0
Vlad
Telerik team
answered on 11 Jan 2011, 08:26 AM
Hello,

 You you will get correct behavior no matter if the column is created programmatically or declared in XAML. You can check the attachment for reference.  

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
Julien
Top achievements
Rank 1
answered on 11 Jan 2011, 02:18 PM
Thanks again for your quick response.  Your sample project uses binding in xaml.  I cannot do this as I do not know the column names before runtime.  For example, account xyz is selected by a user and the columns are generated at runtime based on the accout number that is selected by the user (ie I cannot have <TextBlock Text="{Binding [ID]}" /> since I don't know the name of the columns ahead of time).  This is why I like to use I DataTable as I can just create the desired columns at runtime.

Please let me know.

Julien
0
Vlad
Telerik team
answered on 11 Jan 2011, 02:33 PM
Hello,

 In this case you may need to create your RowDetailsTemplate programmatically. Recently Pete Brown posted very good blog post related to this. You can check it here.

Best wishes,
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>>
Tags
GridView
Asked by
Li
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Li
Top achievements
Rank 1
Leo
Top achievements
Rank 2
Julien
Top achievements
Rank 1
Share this question
or