Detailsview - how do I add the first record?

Discussion in 'ASP .Net' started by JonBosker, Feb 1, 2007.

  1. JonBosker

    JonBosker Guest

    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
     
    JonBosker, Feb 1, 2007
    #1
    1. Advertising

  2. On Feb 1, 10:58 am, "JonBosker" <> wrote:
    > 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();
    }
     
    Alexey Smirnov, Feb 1, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VGRhclRkYXI=?=

    Detailsview adding first record

    =?Utf-8?B?VGRhclRkYXI=?=, Sep 11, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    4,725
    =?Utf-8?B?VGRhclRkYXI=?=
    Sep 12, 2005
  2. André
    Replies:
    0
    Views:
    3,749
    André
    Jun 25, 2006
  3. Frits van Soldt

    How to insert a new record in detailsview when there are no record

    Frits van Soldt, Nov 16, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    749
    Frits van Soldt
    Nov 17, 2005
  4. André
    Replies:
    0
    Views:
    444
    André
    Jun 25, 2006
  5. Inna
    Replies:
    0
    Views:
    1,321
Loading...

Share This Page