locked
Why no textbox for entering the new record in a ListView data control? RRS feed

  • Question

  • User-830563764 posted

    I have a VS2010/ASP.NET4 website.  On a webpage with a DDL and 3 ListViews.  The DDL will select an EmpID to open the 3 ListViews for Edit records and Add new records to the SqlDataSource. 

    The Add function of the ListView displays an Insert and a Cancel buttons, and textboxes for entering the new data.  Two ListViews showed an empty textbox for the EmpID, while the other one did not display a textbox for the EmpID.  It did show textboxes for other fields. 

    Why?  Any reason why no textbox for entering the EmpID.  In those 3 database entity tables, EmpID is set to be the primary key.   How do I control the EmpID PK be auto-set or textbox entry? 


    Friday, September 30, 2016 7:10 PM

Answers

  • User465171450 posted

    If one of the entity tables doesn't have the primary key as something that isn't going to auto-populate (like a sql identity column) then it will need to make entry available. Normally though, you never want the primary key to be available for data entry except in cases where you are generating data that would be used for development purposes such as a lookup table of set values that you have enums based upon.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 5, 2016 11:11 AM

All replies

  • User-707554951 posted

    Hi wonjartran,
    Form your description. I am not quite clear about you problem, would you please provide us with some code about your problem and more detailed description?
    Best regards
    Cathy

    Sunday, October 2, 2016 5:27 AM
  • User-830563764 posted

    I think I understood why there is no textbox for entering the EmpID.  Reviewing the schema of the database, I found the Identity property of EmpID is set to true.  That is the EmpID will have the Autonumber.   

    Tuesday, October 4, 2016 8:53 PM
  • User465171450 posted

    If one of the entity tables doesn't have the primary key as something that isn't going to auto-populate (like a sql identity column) then it will need to make entry available. Normally though, you never want the primary key to be available for data entry except in cases where you are generating data that would be used for development purposes such as a lookup table of set values that you have enums based upon.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 5, 2016 11:11 AM