Visible Property Set to False Inserts Null Value in Database

Discussion in 'ASP .Net' started by needin4mation@gmail.com, Oct 11, 2006.

  1. Guest

    Hi, I have a employee and address table. the address table has an
    addressid and and employeeid. I have two datagrids, an employee and
    address.

    The employee datagrid has a select. Clicking the select will product
    the detail address grid.

    If I hide the employeeid in the address table and set the column with
    visible=false and update the row, I get a null in the database and
    therefore cannot connect that employee to their address. If I set the
    column to visible=true, then I can insert the data as expected.

    I have searched, but must be searching on the wrong thing. I also have
    tried setting the style class with visibility=hidden. This style hides
    the data, but there is still a blank column showing.

    What can I do? Thank you.
    , Oct 11, 2006
    #1
    1. Advertising

  2. Siva M Guest

    I have not tried this before but can you keep the employee Id in in a
    HiddenField and make it part of another column itself, say Address Line 1
    (via template column) ? This way it wont be visible but still your Update
    could work?

    <> wrote in message
    news:...
    Hi, I have a employee and address table. the address table has an
    addressid and and employeeid. I have two datagrids, an employee and
    address.

    The employee datagrid has a select. Clicking the select will product
    the detail address grid.

    If I hide the employeeid in the address table and set the column with
    visible=false and update the row, I get a null in the database and
    therefore cannot connect that employee to their address. If I set the
    column to visible=true, then I can insert the data as expected.

    I have searched, but must be searching on the wrong thing. I also have
    tried setting the style class with visibility=hidden. This style hides
    the data, but there is still a blank column showing.

    What can I do? Thank you.
    Siva M, Oct 12, 2006
    #2
    1. Advertising

  3. Guest

    I found that by using datakeynames I could put a comma separated list
    of keys. This is by design for security, according to Microsoft. It
    is also documented that if you want a field that retains its values in
    postback (you have access to the array that holds the data) and want an
    invisible field (visible=false), then you must you the datakeynames
    property.

    But I think a hidden control (not field) would work. I simply didn't
    want to go that route because it felt like a "hack" instead of the
    proper design methodology (no offense, I had considered this already
    before your post and decided against it, unless there was no other
    alternative.)

    Thanks.


    Siva M wrote:
    > I have not tried this before but can you keep the employee Id in in a
    > HiddenField and make it part of another column itself, say Address Line 1
    > (via template column) ? This way it wont be visible but still your Update
    > could work?
    >
    > <> wrote in message
    > news:...
    > Hi, I have a employee and address table. the address table has an
    > addressid and and employeeid. I have two datagrids, an employee and
    > address.
    >
    > The employee datagrid has a select. Clicking the select will product
    > the detail address grid.
    >
    > If I hide the employeeid in the address table and set the column with
    > visible=false and update the row, I get a null in the database and
    > therefore cannot connect that employee to their address. If I set the
    > column to visible=true, then I can insert the data as expected.
    >
    > I have searched, but must be searching on the wrong thing. I also have
    > tried setting the style class with visibility=hidden. This style hides
    > the data, but there is still a blank column showing.
    >
    > What can I do? Thank you.
    , Oct 12, 2006
    #3
    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?bWljaGFlbHM=?=
    Replies:
    0
    Views:
    336
    =?Utf-8?B?bWljaGFlbHM=?=
    Jun 1, 2006
  2. Mattias Sjögren
    Replies:
    2
    Views:
    579
  3. Andrew Jocelyn
    Replies:
    6
    Views:
    6,511
    Andrew Jocelyn
    Feb 8, 2009
  4. Benjamin Joldersma

    Visible property keeps resetting to False

    Benjamin Joldersma, Oct 17, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    134
    Jim Cheshire [MSFT]
    Oct 18, 2003
  5. Jurjen de Groot
    Replies:
    0
    Views:
    297
    Jurjen de Groot
    May 19, 2008
Loading...

Share This Page