I have an entity with a string primary key ( nvarchar(2)
in the database ).
My issue is - In my Dynamic Data application, the Insert.aspx page does not render the Insert and Cancel buttons.
My question is - do I need to mark the primary key with any special attribute?
PS - I believe this is related to the primary key. I have another entity with an integer primary key, which is automatically generated ( identity(1,1)
), and the Insert and Cancel buttons are rendering accordingly.
Much, much appreciated.
Edit:
I found that the issue is related to primary keys not being auto-generated. I have an entity with an auto-generated integer primary key and it works just fine. On the other hand, if the primary key is an integer but not auto-generated, I observe the issue described above. Again, much appreciated.
So the issue was that the Insert LinkButton
in Insert.aspx was not rendered when the primary key was a string (and consequently not auto-generated) (the same issue occurred in with the Edit LinkButton
in Edit.aspx).
I tried changing the StoredGeneratedPattern
in the EDMX designer with no luck.
At the end, this did for me - open Insert.aspx and locate these two LinkButtons
:
<asp:LinkButton runat="server" CommandName="Update" Text="Update" CssClass="button" />
<asp:LinkButton runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" CssClass="button" />
Simply replace the LinkButtons
to just Buttons
. Make sure to validate that the entered primary key is not already in the database. Thank you.