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
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.
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.
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.
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); .
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
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.
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
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
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
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
Can u pls give ur example.
I use Linq to generate a new datasource.
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.
Julian Benkov
the Telerik team
SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).