RadGridView generating columns manually?

3 posts, 1 answers
  1. Enric
    Enric avatar
    32 posts
    Member since:
    Apr 2013

    Posted 04 Sep 2013 Link to this post

    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. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 05 Sep 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Enric
    Enric avatar
    32 posts
    Member since:
    Apr 2013

    Posted 05 Sep 2013 Link to this post

    yes, thanks a lot
Back to Top