In a scaffolded page in ASP.NET Dynamic Data, if the entity has a foreign key field, and the value you seek is not in the the primary key table, i.e. is not in the drop-down, you have to abandon your edits to the entity, add the sought foreign key value to its table, and return to your original entity.
How could I go about adding a 'New' link/button to the foreign key field template, that would open a new window (make a Panel visible) where you can add the sought value, and then refresh the drop-down?
Best Answer
You mean like in the django admin ui ;). I'm currently trying to implement that feature, i'll post the code here if I get it to work.
EDIT:
Ok, I got that to work, complete django style... It's kinda long to explain but simple in fact.
Files to create:
A admin_popup.master to have a nice popup page (copy the admin.master without the header).
A popup_Insert.aspx with admin_popup.master as master. (copy the Insert.aspx)
Modifications
To your admin.master.cs: add this:
In your admin_popup.master, add these attributes to the body tag (it's used to resize the poup)
In your admin_popup.master.cs
In popup_Insert.aspx.cs, replace these two functions:
In ForeignKey_Edit.ascx, add a LinkButton (ID=LinkButton1) and in ForeignKey_Edit.ascx.cs, replace that function
And finally the two extentions functions I use (put it where you want to):
In your global.asax, register the new route by changing that line:
Ok I hope i didn't forgot anything... It certainly could be improved, but it works. Ok I hope some people will fint that useful, it makes ASP.NET Dynamic Data a lot more better ;). I'm goind to take a look at many-to-many relationships now.