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

[Solved] RadGridView ItemsSource ?

5 Answers 454 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marjeta Segrec
Top achievements
Rank 1
Marjeta Segrec asked on 28 Jan 2009, 08:17 PM
Hello.

In my Silverlight project I'm using for Data manipulation C1.Silverlight.Data.DataView (ComponentOne). When I set RadGrid ItemsSource is RadGrid empty (not populated with data). What is the problem ?

Private Sub PopulateData()

        Me.RadGrid.AutoGenerateColumns = True
        '
        Dim dt As New C1.Silverlight.Data.DataTable("Customers")
        '
        dt.Columns.Add("FirstName", Type.GetType("System.String"))
        dt.Columns.Add("LastName", Type.GetType("System.String"))
        '
        For a As Integer = 0 To 10
            Dim newRow As C1.Silverlight.Data.DataRow = dt.NewRow
            '
            newRow("FirstName") = String.Concat("FirstName_", a)
            newRow("LastName") = String.Concat("LastName_", a)
            '
            dt.Rows.Add(newRow)

        Next ' a As Integer = 0 To 10
        '
        Me.RadGrid.ItemsSource = dt.DefaultView
End Sub ' PopulateData()

 

Thanks for your answer.

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 29 Jan 2009, 09:43 AM
Hello Marjeta,

Unfortunately you cannot achieve this using auto-generated columns. I've made for you small demo to illustrate you how this can be done (attached).

Regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
James
Top achievements
Rank 1
answered on 18 Aug 2009, 06:20 AM
Hi Vlad,

I had a look of your demo, but it doesn't show how to archive auto-generated columns.. you used fixed columns: ID and Name.

I want to archive auto-generated columns in RadGridView with this http://silverlightdataset.codeplex.com/. Do you have a demo?

 <telerik:RadGridView Name="RadGridView1" AutoGenerateColumns="False">
            <telerik:RadGridView.Columns>
                <telerikGridView:GridViewDataColumn HeaderText="ID" DataMemberPath="ID">
                    <telerikGridView:GridViewDataColumn.CellStyle>
                        <Style TargetType="telerikGridView:GridViewCell">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="telerikGridView:GridViewCell">
                                        <TextBlock Text="{Binding ID}" />
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </telerikGridView:GridViewDataColumn.CellStyle>
                </telerikGridView:GridViewDataColumn>
                <telerikGridView:GridViewDataColumn HeaderText="Name" DataMemberPath="Name">
                    <telerikGridView:GridViewDataColumn.CellStyle>
                        <Style TargetType="telerikGridView:GridViewCell">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="telerikGridView:GridViewCell">
                                        <TextBlock Text="{Binding Name}" />
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </telerikGridView:GridViewDataColumn.CellStyle>
                </telerikGridView:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
0
Vlad
Telerik team
answered on 18 Aug 2009, 06:23 AM
Hello James,

Please check this blog post for more info:
http://blogs.telerik.com/vladimirenchev/posts/09-04-23/lightweight_datatable_for_your_silverlight_applications.aspx

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
James
Top achievements
Rank 1
answered on 18 Aug 2009, 08:28 AM
it works (I found it needs to remove the AutoGeneratedColumn="True")
Thanks very much!
0
James
Top achievements
Rank 1
answered on 18 Aug 2009, 08:33 AM
Vlad,

ColumnsWidthMode="Fill" seems not working either in xmal or in code.
Tags
GridView
Asked by
Marjeta Segrec
Top achievements
Rank 1
Answers by
Vlad
Telerik team
James
Top achievements
Rank 1
Share this question
or