Last post Jul 22, 2006 05:30 AM by Dave Sussman
Jul 21, 2006 10:37 AM|Dave Sussman|LINK
First off, blinq rocks. I was at a company yesterday giving 70 developers a talk on the new ASP.NET 2.0 features and finished with blinq, saying "all that data stuff I just showed - forget it, just type this and it does it for you". They were pretty excited
by the data source controls and new grids until they saw the future, then they were amazed.
So, to the request. Since you're examining the db schema, it would be good to add the option for selection lists for lookup tables to be added to the target page when it's created. That is, when seeing a foreign key such as CategoryID, offer the option of
automatically creating a DropDownList for the grid/detailsview when in Edit/Insert mode. It just saves that bother of having to template the fields every time.
On that note, since you wrote the controls (and yes, I'm digressing here), I wonder if there's some way to have a combined EditItemTemplate/InsertItemTemplate as they are often the same (eg the afore-mentioned DropDownList). The two methods I can think of
are having an EditInsertItemTemplate, or by addition of an attribute to indicate the content of another template is to be used (eg <InsertItemTemplate copyTemplate="EditItemTemplate" />)
Jul 21, 2006 07:00 PM|phuff|LINK
Thanks, Dave- I'm glad you like it!
Can you explain your first request a little more in detail? You should already automatically get DropDownLists in the EditItemTemplate and InsertItemTemplate of TemplateFields for all fields that are foreign key fields. Are you asking for a feature that
would allow you to choose which field would show up in the edit mode DropDownLists for foreign key fields?
Both the TemplateField used by DetailsView, and the templates on FormView, have the feature you describe. If you don't declare the InsertItemTemplate, the EditItemTemplate is used in insert mode. Make sure you don't have an empty InsertItemTemplate to
use this feature- you must have no InsertItemTemplate declared at all.
Jul 22, 2006 05:30 AM|Dave Sussman|LINK
You know what? I'm lame and you're several steps ahead of me. I just assumed it didn't do the automatic DropDownList, but it's me being completely useless; I happened to pick a page based upon a table that didn't have the foreign key I though it had. Clock
this on up as "stupid user error".
With regard to the InsertItemTemplate on the DetailsView, all I can say is wow - I never knew this. I've been writing and speaking about 2.0 for a long time and have always assumed that both templates were required. The docs (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.templatefield.edititemtemplate.aspx)
certainly don't mention this behaviour and I've not found any other discussion of it. You should blog this, or get Scott to since he's been linking to lots of data articles recently.