Visible Property Set to False Inserts Null Value in Database

N

needin4mation

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.
 
S

Siva M

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?

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.
 
N

needin4mation

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top