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

Rebinding the RadGridView on a button's click event

13 Answers 776 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sandeep Pulkundwar
Top achievements
Rank 1
Sandeep Pulkundwar asked on 07 May 2009, 06:15 PM
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?

13 Answers, 1 is accepted

Sort by
0
gerbrand
Top achievements
Rank 2
answered on 08 May 2009, 06:41 AM
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.




0
Deyan
Telerik team
answered on 08 May 2009, 07:32 AM
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.
0
Bogdan
Top achievements
Rank 1
answered on 01 Jun 2009, 02:56 AM
I have the same problem. I bind my list from data base.
0
Deyan
Telerik team
answered on 01 Jun 2009, 11:54 AM
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.
0
Bogdan
Top achievements
Rank 1
answered on 02 Jun 2009, 03:05 AM
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); .

0
Prad
Top achievements
Rank 2
answered on 02 Jun 2009, 04:22 PM
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
0
Deyan
Telerik team
answered on 03 Jun 2009, 09:27 AM
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.
0
Neerav
Top achievements
Rank 1
answered on 09 Dec 2010, 03:12 PM

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

0
Iana Tsolova
Telerik team
answered on 13 Dec 2010, 02:55 PM
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.
0
Neerav
Top achievements
Rank 1
answered on 21 Dec 2010, 01:52 PM
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
0
Julian Benkov
Telerik team
answered on 23 Dec 2010, 12:13 PM
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.
0
prat
Top achievements
Rank 1
answered on 09 Jan 2012, 06:13 AM
hi Prad,


Can u pls give ur example.
I use Linq to generate a new datasource.
0
Julian Benkov
Telerik team
answered on 11 Jan 2012, 06:13 PM
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).

Tags
GridView
Asked by
Sandeep Pulkundwar
Top achievements
Rank 1
Answers by
gerbrand
Top achievements
Rank 2
Deyan
Telerik team
Bogdan
Top achievements
Rank 1
Prad
Top achievements
Rank 2
Neerav
Top achievements
Rank 1
Iana Tsolova
Telerik team
Julian Benkov
Telerik team
prat
Top achievements
Rank 1
Share this question
or