I am having an SQL Server database, which is having a lots of table. Each of the table is having a primary column, which in fact is a GUID column. I have created new ASP.NET Dynamic data site to manage these tables. The problem is that, the GUIDs are not being generated and that's why the site breaks for all tables.
I tried by adding "newID()" in SQL table, but it still fails. I believe I need to somehow do changes in code. I believe this might be an issue faced by many developers working with ASP.Net Dynamic site.. Any idea of how to fix this?
I have added following code in "Inserting" event of a FormView Control in ~PageTemplates\Insert.aspx.
As all my tables have a consistent naming convension as Id represents PK column, I am fine to use this hard-coded column name, or else, you may need to write appropriate logic to find PK column.
I think I cheated but I just created a new GUID Field template. To use create the extension metadata for your class. Shortened version shown here. And associate it with your class.
Then add the GUID.ascx and GUID_Edit.ascx to your project. When you insert a new record a GUID will be generated and show up read only in your form. Key is making the UIHint to be a GUID type.
Code below...
--- EventCalendarMetadata.cs
--- GUID.ascx
--- GUID.ascx.cs namespace DFEventsWeb {
--- GUID_Edit.ascx
--- GUID_Edit.ascx.cs