c# - ASP.NET Insert Only Details View with Drop Down List -
i using asp.net webforms , entity framework. i'm trying have simple insert form using details view. not want edit, delete, or select entries details view, insert new entries.
in insert, want insert new people. structure of person is: name, manager, location
i have 2 entity data sources, 1 represents managers , 1 represents locations have 2 dropdownlists in insertitemtemplate can select manager , location.
my problem when place detailsview (defaultmode = insert) , add data source people entity, detailsview shows entry database drop down lists , name fields. might missing simple can't seem detailsview insert has dropdownlists populated other entity data sources.
<asp:detailsview id="detailsview1" runat="server" height="50px" width="125px" defaultmode="insert" autogenerateinsertbutton="true"> <fields> <asp:boundfield datafield = "name" /> <asp:templatefield> <insertitemtemplate> <asp:dropdownlist datasourceid = "managerentitysource" runat="server" /> </insertitemtemplate> <insertitemtemplate> <asp:dropdownlist datasourceid = "locationentitysource" runat="server" /> </insertitemtemplate> </asp:templatefield> </fields> </asp:detailsview> <asp:entitydatasource id="addemployeedatasource" runat="server" connectionstring="name=safetyentities" defaultcontainername="safetyentities" enableflattening="false" enableinsert="true" entitysetname="employees"> </asp:entitydatasource>
not sure if help, if want insert mode, try removing autogenerateinsertbutton property, , add commandfield showinsertbutton = true in fields property.
<asp:detailsview id="detailsview1" runat="server" height="50px" width="125px" defaultmode="insert"> <fields> <asp:boundfield datafield = "name" /> <asp:templatefield> <insertitemtemplate> <asp:dropdownlist datasourceid = "managerentitysource" runat="server" /> </insertitemtemplate> <insertitemtemplate> <asp:dropdownlist datasourceid = "locationentitysource" runat="server" /> </insertitemtemplate> </asp:templatefield> <asp:commandfield showinsertbutton="true" /> </fields> </asp:detailsview>
Comments
Post a Comment