newuser
2012-11-15T08:24:29Z
I have a datatable which has columns and rows in it.

I want to add all column's information and few rows depending on two variables (_firstIndex and _lastIndex) from datatable into datagrid.

how do i accomplish this?

for e.g. the logic should be something like below---
(the following code doesnt work but it gives an idea on what i want)

theDataGridView.Cols.AddRange(datatable.Columns);
for (int i = _firstIndex; i < datatable.Rows.Count && i <= _lastIndex; i++)
{
theDataGridView.Rows.Add(datatable.Rows[i]);
}


/*
My data is bunch of rows from a database which may or may not have primary key. I am trying to use 10tec igrid to display only 20 of these rows at a time. There will be options for "Next Page" and "Last Page" which will fetch me the next or last 20 rows.
*/
Igor/10Tec
2012-11-15T13:04:35Z
First, you should try to use iGrid.NET's FillWithData method to populate the grid. It will create the corresponding column set automatically and will add the rows without coding loops. You can pass such objects as DataTable and DataView into this method, so the question is how to fetch the required rows from the original DataTable.

To solve it, we need to know what data are stored in it. If the DataTable already has something like row number, or a key which can be used to filter it - just create a DataView on your DataTable and feed it to FillWithData. If not, then you can create a primary key for your table on-the-fly and use it to filter.

If you wish, you can send us an example of your data, and we'll give you a solution.
newuser
2012-11-16T06:40:54Z
My data may or may not contain primary key. its a bunch or rows i am getting from database server. the feature i am creating is a SHOW DATA gui which will display 20 rows of database per page and have options like "next page"(to display next 20 rows) and "last page" (to display last 20 rows). I am using 10tec igrid for displaying the data i am fetching
Igor/10Tec
2012-11-16T10:40:27Z
If you implement this functionality, then the best choice is to request a next portion of data directly from the database when the user presses the Next Page button. If you use Transact-SQL, the built-in ROW_NUMBER function can help you in that:

http://msdn.microsoft.com/en-us/library/ms186734.aspx 

If your logic fetches all data at once, and you need to display them by pages in iGrid, then you can simply add a new column like primary key to your local DataTable, init it with natural numbers after retrieving data in a simple loop, and then use DataView to "fetch" a next page by filtering by these row numbers.

But do you want to say that it would be better if we just added two more parameters to the FillWithData method - the staring row, and the end row?
newuser
2012-11-16T10:44:24Z
Originally Posted by: Igor/10Tec 

If you implement this functionality, then the best choice is to request a next portion of data directly from the database when the user presses the Next Page button. If you use Transact-SQL, the built-in ROW_NUMBER function can help you in that:

http://msdn.microsoft.com/en-us/library/ms186734.aspx 

If your logic fetches all data at once, and you need to display them by pages in iGrid, then you can simply add a new column like primary key to your local DataTable, init it with natural numbers after retrieving data in a simple loop, and then use DataView to "fetch" a next page by filtering by these row numbers.

But do you want to say that it would be better if we just added two more parameters to the FillWithData method - the staring row, and the end row?



That will be great..!! :)
Igor/10Tec
2012-11-16T13:45:39Z
The development of the next big update of iGrid.NET is in progress, and this feature has been added to the to-do list for the new version.
Igor/10Tec
2013-02-25T12:15:54Z
The requested feature is now a part of the built-in iGrid.NET functionality. The recently released v4.5 has the following overloaded version of the FillWithData method:

public void FillWithData(object dataSource, bool useCurColSet, 
  string rowKeyCol, bool addRowKeyCol, 
  string rowLevelCol, bool addRowLevelCol, bool addTreeButtons, 
  int dataStartRow, int dataRowCount)

To gain the goal, use the last two parameters dataStartRow and dataRowCount.
newuser
2013-02-25T14:23:10Z
Thanks for implementing this feature. This will help me a lot in my projects.