Hi Ivan,
If your DataTable has a unique integral column, such as an ID, then sort on
that column when querying the database and bind the list to a DataView that
is also sorted on the ID column. When you add a new row you can set the ID
to one less than the smallest ID value so that it's sorted first by the
DataView:
// table is a DataTable
newRow.ID = (int) table.Compute("MIN(ID)-1");
If you are already sorting the data but not by ID, or if you don't have a
unique integral column on which to sort, then you can add an AutoNumber
column typed as Int32 before you fill the DataTable (assuming that any sort
algorithm has already been performed, such as with an ORDER BY clause in a
database query). Each row will be assigned an incrementing integer starting
from zero. The same code above will apply.
--
Dave Sexton
"Ivan Sammut" <sa*****@hotmail.comwrote in message
news:O6**************@TK2MSFTNGP02.phx.gbl...
>I have an asp webpage on which I have a dropdownlist which I fill from my
database using Datasets. Now I want to add an empty record in the dataset
so the first option of the list is empty but I can only append a record at
the end of the Dataset. Any one has an idea on how I can achieve to append
a record at the top of my dataset.
Thanks
Ivan Sammut