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

RadGridView generating columns manually?

2 Answers 56 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Enric
Top achievements
Rank 1
Enric asked on 04 Sep 2013, 10:45 PM
Hi there,
.
I'm a newbie with this control. Now I'm using it directly binded to one dataset.

XAML:

 <telerik:RadGridView x:Name="dgvOrdenes" ShowGroupPanel="False" ShowColumnHeaders="True" ShowColumnFooters="False"
                             ItemsSource="{Binding V_Or2}" HorizontalAlignment="Left"
                             Margin="10,44,0,0" ShowInsertRow="False" VerticalAlignment="Top" Height="216"
                             Width="405" Grid.ColumnSpan="2" Grid.RowSpan="4" >

Code-behind:

        Dim connexio As SqlConnection
        Dim ada As New SqlDataAdapter()
        Dim ds As New DataSet

        connexio = New SqlConnection("Server='ENRIC-PC\ENRIC';Initial Catalog=****;User ID=*****Password=******;current language=spanish")


        connexio.Open()


        ada = New SqlDataAdapter("select * from V_Or2", connexio)
        ada.Fill(ds, "V_Or2")
        Me.dgvOrdenes.DataContext = ds



I'd like to assign manually every column but using the same code-behind, how can I do that?
Obviously this doesn't work ("Modelo" is one of the views' Sql Server fields returned)

            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding V_Or2.Modelo}" Header="First Name" UniqueName="FirstName" />
            </telerik:RadGridView.Columns>

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 05 Sep 2013, 10:16 AM
Hi,

You should set the ItemsSource for the RadGridView to be the DefaultView of the table you are interested in (for example V_Or2).

Then set the Binding to:

<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Modelo}" Header="First Name" UniqueName="FirstName" />
</telerik:RadGridView.Columns>

How does this work for you?

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Enric
Top achievements
Rank 1
answered on 05 Sep 2013, 10:26 PM
yes, thanks a lot
Tags
General Discussions
Asked by
Enric
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Enric
Top achievements
Rank 1
Share this question
or