Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid????

Status
Not open for further replies.

akshita

Programmer
Mar 26, 2002
25
0
0
IN
hi friends,

is it possible to add new row in between the datagrid.with the code i am using i'm able to add new row at the end but i want to insert in between.

akshita
 
If this is a bound DB grid (not to confuse with a Flex Grid) based on a recordset - no you cannot do it - not with-out a sort order:
If it is placed now into the middle, then when the form with the grid is opened again, it should still be in the middle. Right? and the only way to do this is to use some type of Sorting on the recordset. Then you only need to resort the recordset after adding the record.
Other than that: No you cannot. (please note that you could do this by creating a temporary table or a 2nd recordset, copying the data row by row from the Grids datasource to the temp recordset or table record by record, and when you come to the position where you need to add the new record, add the record, then continue with the rest, delete all from the data source and set the data source of the grid to the 2nd recordset -alot of work)


 
can u plzz tell me what is the diff in bound datagrid and unbound datagrid
 
A bound datagrid is like the word inplies -it is bound/binded/tied to a recordset or datacontrol object. All actions in the grid will affect the recordset and possible a database table if the recordset is opened on it.

An Unbound grid is not tied to a recordset - you need to fill the cells with data - it will not happen automatically.

You can see if the grid is bound by checking its' datasource property in the properties window or in code - is it assigned to a recordset or datacontrol - more than likely - then it is bound.

The problem in your case is that the data that is pulled into the grid is either in the "physical" order (other readers please let's not get into a discussion about this here - I am saying physical to just make it easier to understand) that it is in the database table, which you just cannot place a new record anywhere you want in this type of Db, but only on the end of it, or in a specific order defined by the recordset/cursor.
The data on a bound grid -is based on one of these orders, and the records have to remain in this order until you set a new sort order on the recordset, with-out getting into more details.

You might want to consider using a ListView, (if you are not dealing with more than 1,000 records) create a recordset object based on a database table and loop through the records, adding them to the ListView Control - but that is another question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top