Need to use RadGrid in code, but not on form

3 posts, 0 answers
  1. Mark
    Mark avatar
    130 posts
    Member since:
    Oct 2014

    Posted 07 Aug Link to this post

    I need to use a RadGridView, so I can assign the DataSource.

     

    However, when I do the following code, i get zero rows and columns.  What am I missing

     

     

    List<Records> data = dbc.Records.ToList();
    RadGridView gv = new  RadGridView();
    gv.BeginUpdate();
    gv.AutoGenerateColumns = true;
    gv.AutoGenerateHierarchy = true;
    gv.DataSource = data;
    gv.EndUpdate();

     

     

    When I look at the gridview, after the datasource is set, the row count and column count are zero?  Again, What I am doing wrong? The only thing that is different then what we are doing in our application, is the grid is not on a FORM.

     

    Thanks

  2. Mark
    Mark avatar
    130 posts
    Member since:
    Oct 2014

    Posted 07 Aug in reply to Mark Link to this post

    Okay, after doing some more searching..i found that I have to initialize the BindingContext.  

     

     

     

  3. Nadya
    Admin
    Nadya avatar
    392 posts

    Posted 10 Aug Link to this post

    Hi, Mark,

    I am glad that you have already managed to found out why your grid remains empty after setting the DataSource. Initializing manually the BindingContext is required when you create and bind RadGridView programmatically in the code.

    Please let me know if you have other questions.

    Regards,
    Nadya
    Progress Telerik

Back to Top