Detailsview - how do I add the first record?

  • Thread starter Thread starter JonBosker
  • Start date Start date
J

JonBosker

Help...

I have a brand new database table and I open the page that has a
DetailsView control that is bound to that table it does not show
anything - not even a new button - so how can I add the first
record??

The reason I ask is because I have a generic page that will display
data from any table. Therefore I cannot add the row programmatically
-
I have tried adding blank values (by querying the SQL Server schema
(SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_NAME = MyTable) but that does not work if the table has foreign
key constraints etc..

Any ideas?

Thanks in advance,
Jon

dbgurus.com.au
 
Help...

I have a brand new database table and I open the page that has a
DetailsView control that is bound to that table it does not show
anything - not even a new button - so how can I add the first
record??

The reason I ask is because I have a generic page that will display
data from any table. Therefore I cannot add the row programmatically
-
I have tried adding blank values (by querying the SQL Server schema
(SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_NAME = MyTable) but that does not work if the table has foreign
key constraints etc..

SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_NAME = MyTable

will return you result when it exists.

That is you have to insert the row into COLUMNS before.

For example (abstract)

if (table_has_no_rows)
{
insert_row();
} else {
get_rows();
}
 
Back
Top