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

Dynamic Binding to Data Table

1 Answer 84 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Matt Tapia
Top achievements
Rank 1
Matt Tapia asked on 21 Sep 2009, 07:14 PM
I am dynamically binding the .ItemsSource and .DataContext property to a datatable in code like such:

 

Dim myDataTable As New DataTable

 

myDataTable = GetDataTable() 'returns datatable with multiple rows

 

 

Me.myRadCarousel.ItemsSource = myDataTable

However, the carousel shows blank images, even though they exist. I double-click on the carousel to get the file name and I get the file name no issue. my datatable contains 1 field (filename)

 

<

 

Window.Resources>

 

 

 

 

 

 

<Style TargetType="{x:Type telerik:CarouselDataRecordPresenter}">

 

 

 

 

 

 

<Setter Property="Template">

 

 

 

 

 

 

<Setter.Value>

 

 

 

 

 

 

<ControlTemplate TargetType="{x:Type telerik:CarouselDataRecordPresenter}">

 

 

 

 

 

 

<Grid IsHitTestVisible="False" HorizontalAlignment="Stretch"

 

 

 

 

 

VerticalAlignment="Stretch">

 

 

 

 

 

 

<Image Source="{Binding Path=Fields[filename].Value}" Height="400" Width="400" />

 

 

 

 

 

 

</Grid>

 

 

 

 

 

 

</ControlTemplate>

 

 

 

 

 

 

</Setter.Value>

 

 

 

 

 

 

</Setter>

 

 

 

 

 

 

</Style>

 

 

 

 

 

 

</Window.Resources>

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Milan
Telerik team
answered on 23 Sep 2009, 03:09 PM
Hi Matt Tapia,

It seems that the binding to Fields[filename].Value is incorrect. Could you try to setup your binding like that:

<Image Source="{Binding Path=Data[filename]}" Height="400" Width="400" />   
<!--Where "filename" is a column name of your DataRow--> 


Data[FirstName]

Best wishes,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Carousel
Asked by
Matt Tapia
Top achievements
Rank 1
Answers by
Milan
Telerik team
Share this question
or