Rebinding the RadGridView on a button's click event

14 posts, 0 answers
  1. Sandeep Pulkundwar
    Sandeep Pulkundwar avatar
    23 posts
    Member since:
    Jan 2009

    Posted 07 May 2009 Link to this post

    Hi,
        There is a button on my form on the click of which I am creating a local object, adding that object to a generic list. I want to rebind my RadGridView to that list every time there is a click fired. Is it possible?
  2. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 08 May 2009 Link to this post

    Yes this is possible.

    I've got something similar. Every time I click one of my buttons I call a function that first clears the rows and then loads my hierarchy grid with the updated generic list.

    Everything is done with code. Do you bind your generic list by code or by datasource?
    Maybe I can give you an example.




  3. UI for WinForms is Visual Studio 2017 Ready
  4. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 08 May 2009 Link to this post

    Hi Sandeep,

    Thanks for your question.

    You can easily rebind your RadGridView with a new source object by setting the RadGridView.DataSource  property to null and after that assigning your new Data Source object.

    You can take a look at the GridView -> Populating with Data - > Databinding example of RadGridView control in our Demos Application. There you can find an implementation of a similar scenario.

    I hope this helps. Do not hesitate to write back if you have further questions.

    Best wishes,
    Deyan
    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.
  5. Bogdan
    Bogdan avatar
    4 posts
    Member since:
    May 2009

    Posted 31 May 2009 Link to this post

    I have the same problem. I bind my list from data base.
  6. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 01 Jun 2009 Link to this post

    Hello Bogdan,

    Take a look at the code of RadGridView examples within our Demo Application that is installed with our controls suite. There are samples which demonstrate how to rebind your RadGridView with another datasource.

    I hope this will help. Do not hesitate to write back if you need further assistance.

    All the best,
    Deyan
    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.
  7. Bogdan
    Bogdan avatar
    4 posts
    Member since:
    May 2009

    Posted 01 Jun 2009 Link to this post

    I dont solve my problem. I looked in this:
      private void BindToDataReader()
            {
                this.radGridView1.MasterGridViewTemplate.AllowAddNewRow = false;
                this.radGridView1.MasterGridViewTemplate.AutoGenerateColumns = true;
                this.radGridView1.MasterGridViewTemplate.EnableGrouping = true;

                this.radGridView1.GridElement.BeginUpdate();

                OleDbCommand command = new OleDbCommand("SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, PostalCode FROM Customers");
                command.Connection = new OleDbConnection(Settings.Default.NwindConnectionString);
                command.Connection.Open();

                this.radGridView1.MasterGridViewTemplate.LoadFrom(command.ExecuteReader());
                command.Connection.Close();

                for (int i = 0; i < radGridView1.MasterGridViewTemplate.Columns.Count; i++)
                {
                    this.radGridView1.MasterGridViewTemplate.Columns[i].Width = 102;
                }

                this.radGridView1.GridElement.EndUpdate();
            }
    but this not work on my program. In this code is the problem    command.Connection = new OleDbConnection(Settings.Default.NwindConnectionString); .

  8. Prad
    Prad avatar
    35 posts
    Member since:
    Apr 2008

    Posted 02 Jun 2009 Link to this post

    I suggest not to use RadGridView.DataSource = null until the next release is out. ( june 2009)

    If you have custom settings (like conditional format/filters) on the grid and on setting of RadGridView.DataSource = null will lead to unhandled exception (internal to telerik).

    I suggest using RadGridView.Columns.Clear() as a work around.

    Pradeep
  9. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 03 Jun 2009 Link to this post

    Hi Bogdan,

    The code in the example uses a sample database to demonstrate the functionality of RadGridView control. If you would like to use this code, then you should modify it according to the specifications of your application regarding database connectivity.

    However, I would like to ask you for a sample application that demonstrates your issue so that I can investigate it and provide proper support.

    Please note that you will have to open a new support ticket to send me your project since you are not able to upload attachments in Forum posts.

    Thanks for your time. I am looking forward to receiving the details requested.

    Regards,
    Deyan
    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.
  10. Neerav
    Neerav avatar
    50 posts
    Member since:
    Nov 2010

    Posted 09 Dec 2010 Link to this post

    Hi everyone,

    Attached are the screenshots of what is actually required.

    We have  a "Course/Group Courses" tab page as given in figure 1 of attached screen shot.

    Another tab "Hierarchy/Attributes" tab as given in figure 2 of attached screen shot.

    In figure 2 in "User Hierarchy" tree view I have checked "n,k" which is part of "Test" group, and  in figure 1 I have selected "Test1" from "Course Groups" tree view and there are two courses in "Selected Courses" grid.

    Now in figure 1 you can see there is a "Make Assignment" button which on click displays figure 3 as a new window with a filled radgrid.
    The grid in figure 3 has "Assign To" and "Assign Content" and various other columns.
    The "Assign To" column is  hyperlink with data same as node selected in figure 2 i.e. "Test". I think this is a template column.
    As well as "Assign Content" has values from "Course Groups" and "Selected Courses".
    I want to know as to how to create this grid as shown in figure 3.

    Since I cannot fire select query because all items are coming dynamically, can you let me know how to create the radgrid as shown in figure 3.

    For implementing the current requirement in our prototype, I have used following link
    http://www.telerik.com/help/aspnet-ajax/grdbindingtonullableobjects.html, by which I think I would be able to retrieve data from treeview and grid and create datasource as arraylist for figure3 radgrid. Am I going correct?
    My figure 3 radgrid is declared in aspx page.


    Kindly Reply

  11. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 13 Dec 2010 Link to this post

    Hi Neerav,

    I can see you have posted your questions in the RadGridView for WinForms forum? However we assume you are talking about the RadGrid for ASP.NET AJAX control. Can you confirm?

    Also, from the provided information it is not clear enough what are the issues you encountered. Is it that you are trying to create the grid at runtime, or you do know how to bind it?

    All the best,
    Iana
    the Telerik team
    Get started with RadControls for WinForms with numerous videos and detailed documentation.
  12. Neerav
    Neerav avatar
    50 posts
    Member since:
    Nov 2010

    Posted 21 Dec 2010 Link to this post

    Hello Telerik Staff

    We have been able to find a workaround for our previous problem for the while.

    We have an issue here with RadTreeView.

    PFA the screen shot of our current scenario.

    In "Figure1" we have a tree view "User Hierarchy". This treeview has binded with nodes using serversidecallback load on demand.
     
    Now in "Figure2" there is a "search" option on top of the page. On clicking the magnifying icon the "Search Results" grid gets opened up. Now in the grid you can see there is a "<-" arrow sign which on click will search the corresponding node in "User Hierarchy" and display the node by highlighting it in "User Hierarchy" as displayed in "Figure3" and "Figure4".
     
    "Figure4" is the actual image("Figure3" is for unserstanding purpose about the hierarchy), as it highlights the node to top of the tree("User Hierarchy").
     
    We are trying to implement the same in our demo application.
    Can you suggest us as to how to search such node in "User Hierarchy" and highlighting it in the same at the node to top of the tree("User Hierarchy").
     
    Since our tree is binded by serversidecallback load on demand, using RadTreeView.GetAllNodes() will not work if I search any child node.
    Kindly provide us proper solution to this and let us know if we are not going correct.
     
    Awaiting your reply.
     
    Thanks and Regards
  13. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 23 Dec 2010 Link to this post

    Hello Sandeep,

    Thank you for writing us.

    It seems that your question is related to our ASP.NET Ajax suite. In this case I would kindly ask you to open a new forum thread in the appropriate forum section. This will allow those of our users who are interested in the topic to find the answer more easily.

    Thank you for your cooperation and understanding.

    Kind regards,
    Julian Benkov
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  14. prat
    prat avatar
    10 posts
    Member since:
    Jul 2011

    Posted 09 Jan 2012 Link to this post

    hi Prad,


    Can u pls give ur example.
    I use Linq to generate a new datasource.
  15. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 11 Jan 2012 Link to this post

    Hello Prat,

    Thank you for writing us.

    It seems that your question is related to our ASP.NET Ajax suite. In this case I would kindly ask you to open a new forum thread in the appropriate forum section. This will allow those of our users who are interested in the topic to find the answer more easily.

    Thank you for your cooperation and understanding.

    All the best,
    Julian Benkov
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Back to Top
UI for WinForms is Visual Studio 2017 Ready