I have a customer DDL populated from a table. If I remove a cust from the table because that cust is no longer working here and a user edits a record that had that particular customer in it, an error occurs. How can I avoid this?
Normally I do but there are exceptions where maybe it's not necessary given the type of quest, in this case it's a logic quest. The error is a standard well known one. but if it'll help:
That's the kicker, if I take the customer out of the table and the user edits a record that the customer is in, the error occurs, so I think it has to remain, maybe somehow hide it from the user?
Well yes, if you remove the customer from the table directly, it's going to cause trouble with any foreign keys. So either you use cascade delete at the database to remove all related records, or you should not remove customers and instead do a logical delete
based on a status column of some kind.
vagabond505
Member
356 Points
219 Posts
Dropdownlist logic question
Mar 05, 2012 05:06 PM|LINK
I have a customer DDL populated from a table. If I remove a cust from the table because that cust is no longer working here and a user edits a record that had that particular customer in it, an error occurs. How can I avoid this?
MetalAsp.Net
All-Star
112085 Points
18242 Posts
Moderator
Re: Dropdownlist logic question
Mar 05, 2012 05:13 PM|LINK
basheerkal
Star
10672 Points
2426 Posts
Re: Dropdownlist logic question
Mar 05, 2012 05:19 PM|LINK
If your Udate Query is based on Customer, change it to based on ID or some other field.
Only a wild guess
B
(Talk less..Work more)
vagabond505
Member
356 Points
219 Posts
Re: Dropdownlist logic question
Mar 05, 2012 05:24 PM|LINK
It needs to exist in the table and DDL or else the error appears. I guess I would have figure a way so that it doesn't appear to the user?
The error being:
'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.
MetalAsp.Net
All-Star
112085 Points
18242 Posts
Moderator
Re: Dropdownlist logic question
Mar 05, 2012 05:27 PM|LINK
vagabond505
Member
356 Points
219 Posts
Re: Dropdownlist logic question
Mar 05, 2012 05:48 PM|LINK
Normally I do but there are exceptions where maybe it's not necessary given the type of quest, in this case it's a logic quest. The error is a standard well known one. but if it'll help:
DropDownList1.DataSource = dt;
<asp:DropDownList ID="DropDownList1" runat="server" DataTextField="cust">
</asp:DropDownList>
MetalAsp.Net
All-Star
112085 Points
18242 Posts
Moderator
Re: Dropdownlist logic question
Mar 05, 2012 05:53 PM|LINK
vagabond505
Member
356 Points
219 Posts
Re: Dropdownlist logic question
Mar 05, 2012 06:19 PM|LINK
That's the kicker, if I take the customer out of the table and the user edits a record that the customer is in, the error occurs, so I think it has to remain, maybe somehow hide it from the user?
MetalAsp.Net
All-Star
112085 Points
18242 Posts
Moderator
Re: Dropdownlist logic question
Mar 05, 2012 06:27 PM|LINK
vagabond505
Member
356 Points
219 Posts
Re: Dropdownlist logic question
Mar 05, 2012 06:38 PM|LINK
The records must remain there is true as they need to be worked on. Can you explain about the "logical" delete?