We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ADO.NET or binding support with grid

Thread ID:

Created:

Updated:

Platform:

Replies:

10123 Jan 22,2004 04:48 PM UTC Jan 22,2004 09:17 PM UTC Windows Forms 5
loading
Tags: GridControl
Vivek
Asked On January 22, 2004 04:48 PM UTC

Hi, I know grid support binding with various datasource but I am not sure about "DATACOLUMN" or "DATAROW". Can I bind a "grid column" to a "DATACOLUMN" object? Or Can I bind a "grid column" to a "DATAROW" object? I would really appreciate if I can get a detail document or link to a document for ADO.NET data binding with “SyncFusion grid”. Your help would be helpful. vivek

Administrator [Syncfusion]
Replied On January 22, 2004 05:34 PM UTC

You cannot bind individual DataColumns to columns in a GridDataBounGrid because individual DataColumns do not hod any data. You need both DataColumns and DataRows, and they need to be in a DataTable to complete teh necessary associations. Normally Ado.NET puts DataColumns in a DataTable. And it is this DataTable that you bind to the GriddataBoundGrid. This is exactly the same way the .NET Framework''s Windows Forms DataGrid works. Here is simple code to programatically create a datatable. You first add the DataColumns to the DataTable, and then you add DataRows to the DataTable. Then, all you have to do is to assign the DataTable as the grid''s DataSource.
DataTable dt = new DataTable("MyTable");

int nCols = 4;
int nRows = 10;
for(int i = 0; i < nCols; i++)
	dt.Columns.Add(new DataColumn(string.Format("Col{0}", i)));

for(int i = 0; i < nRows; ++i)
{
	DataRow dr = dt.NewRow();
	for(int j = 0; j < nCols; j++)
		dr[j] = string.Format("row{0} col{1}", i, j);
	dt.Rows.Add(dr);
}
this.gridDataBoundGrid1.DataSource = dt;

Administrator [Syncfusion]
Replied On January 22, 2004 06:35 PM UTC

Clay, Thanks for your quick reply. I was reading the ADO.Net portion on features page on “syncfusion.net” and according to that we can bind a datasource to a cell of the grid, From the website: “ Essential Grid also supports binding individual cells to datasources. Among others, this can come in useful in cases where a Combo Box´s choices need to be based on a query from a foreign table. “ Q#1 (M. Imp) I am wondering is it possible to bind a column or row of grid to some datasource? I am interested in to bound a row or column of grid somehow so that when I need to refresh I don’t have to load whole grid again. I just want to refresh only one row or one column at a time. If there is any efficient way to achieve above please do suggest us. This is the only one evaluation factor which we concerned most. Our grid is heavily database dependent and we don’t want to load full grid again jus for one cell or column or row. Q#2 If I come back to original discussion then I am little confuse. I was reading the book “Developing .NET Custom Controls and Designers using C#” and I found following: *********************************** Data Binding Concepts: For .NET data binding to be possible, there must be providers of data and consumers of data. A provider of data is an object or component that exposes its data to the outside. A consumer is an object or component that uses the data exposes by a provider with the intention to display or modify that data. With .NET data binding, the minimum requirement to support list-based data binding is for the provider to implement the IList interface. The IList interface represents an index-based collection. Data Providers: The following objects implement the IList interface; so they are, inherently, data providers. Arrays DataSet DataTable DataView DataViewManager DataColumn A DataColumn typically represents, and is analogous to, a column in a database table. Although, it may also represent an XML attribute or an attributeless XML element. You can only simple-bind to a DataColumn. This means that only simple controls, such as a text box, can be bound to a DataColumn. ******************************* According to above statement it seems that a DataColumn can be bound. I am little confused here. Is it something specific to “grid” where u can’t bind DataColumn or I am missing something somewhere? Please help me. Thanks Vivek

Administrator [Syncfusion]
Replied On January 22, 2004 07:48 PM UTC

Yes, you can put a combobox in a column, and set the list for the combobox to some second DataSource (normally, a DataTable) specifying a valuemember and a displaymember from teh DataTable. But the actual data in the grid comes from the the grid''s datasource. For example, a column in the grid''s datasource may be something like a CustomerID (an int). In a separate DataTable, there might be a CustomerID column (an int) and a CustomerName column (a string). You can use this second DataTable in a Combobox celltype for the grid column to display the CustomerName in the grid instead of just showing the CustomerID. This is a ''foreign key'' grid column where the displayed values comes from a second DataSource and is matched through this key column. The website information you quoted refers to this particular use case. The celltype must be a ComboBox currently, but you can set properties to actually hide this combobox if you want grid without seeing the combobox. The sample, Syncfusion\Essential Suite\Grid\Samples\DataBound\GDBGcombos, illustrates this process.

Administrator [Syncfusion]
Replied On January 22, 2004 08:03 PM UTC

Thanks clay, could you please provide some input realted to following question? Q. I am wondering is it possible to bind a column or row of grid to some datasource? I am interested in to bound a row or column of grid somehow so that when I need to refresh I don’t have to load whole grid again. I just want to refresh only one row or one column at a time. If there is any efficient way to achieve above please do suggest us. This is the only one evaluation factor which we concerned most. Our grid is heavily database dependent and we don’t want to load full grid again jus for one cell or column or row. waiting for your answer. thanks viveks

Administrator [Syncfusion]
Replied On January 22, 2004 09:17 PM UTC

I may be wrong, but I do not think ADO.NET supports this type of updating scenario. It uses a disconnected architecture, cacheing the dataset locally. Our GridDataBoundGrid is virtually bound to this ADO.Net cached datasource. You do not ''load the data into the grid''. Instead, you use ADO.NET methods to download a disconnected DataSet, and the grid just gets its values as needed (on demand) from this cached data. Now if you application modifies a single row or column or single cell in this cached dataset from outside the grid, then only that row or column or cell is refreshed in the grid. If you have some other type of database support that provides more flexibility than the disconnected ADO.NET achitecture, then you can virtually bind data from this datasource using our GridControl in a virtual mode. In this way, you can easily bind to custom datasources.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;