Last post Jan 29, 2009 11:14 AM by sjnaughton
Jan 29, 2009 06:44 AM|alex999|LINK
I want to use cascading dropdowns in insert / edit mode. My environment: LINQ2SQL, Cassini / IIS6 and VS2008 SP1 with .NET 3.5 SP1.
I tried to setup the cascading dropdowns from this blog: http://csharpbits.notaclue.net/2009/01/dynamic-data-cascading-fieldtemplates.html
The cascading is working, but I can't insert or edit a record. My database model is nearly the same like in the northwind database, mentioned in the blog: I have a details table, a categories table and a products table. The difference is the relation from
details table to product table. My relation consists of three database columns which build the primary key in products table and which is a foreign key in the details table.
When I klick the Insert-Hyperlink, nothing happens. I can see in SQL Server Profiler, that the value of the category-dropdown is set to NULL which is not allowed. Therefore the new record isn't inserted. I checked the generated HTML and there I can see the
correct value-text pairs for the category and product dropdowns. Everything seems to be fine at this point:
<option selected="selected" value="">All</option><option value="9">Cat-A</option><option value="10">Cat-B</option><option value="12">Cat-C</option>
<option value="">All</option><option value="10099">P1</option><option value="10100">P2</option><option value="10101">P3</option>
In SQL Profiler:
exec sp_executesql N'INSERT INTO [dbo].[Details]([Line], [Category], [Product], [Unit], [Activity], ...)VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8)SELECT CONVERT(BigInt,SCOPE_IDENTITY()) AS [value]',N'@p0 varchar(6),@p1 int,@p2 varchar(8000),@p3 varchar(3),@p4 varchar(3),@p5 varchar(3),@p6 varchar(3),@p7 varchar(4),@p8 varchar(7)',@p0='123',@p1=10100,@p2=NULL,@p3='EUR',@p4='Stuff', ...
As you can see here, the order of Category (@p1) and Product (@p2) is wrong also.
Do I have a chance to fix this problem?
Thanks a lot,
Jan 29, 2009 11:14 AM|sjnaughton|LINK
This issue there is that the in the standard table OrderID and ProductID both in the Primary key to test this you will have to butcher you Northwind or create some tables that simulate what you want. What version of SQL Server are you running is 2008 I can
probably send you my buchered version of Northwind for you to try. I dont bother putting the DB up there anymore as there are two many version required and it's a pain to make each version. [:(]
If you want my buchered version of Northwind just send me a provate message and I'll send it you by return [:D]