Insert record using DetailsView

saturation
saturation used Ask the Experts™
on
I am trying to arrive at this page below and have a blank form so that I can enter data and save it.  However, when I run the page, I come to a page that has the first record in the DB loaded into the fields with an "insert" button at the bottom, which then takes me to a blank screen.  What am I doing wrong here?
<form id="form1" runat="server">
    <div>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:LandingPageGeneratorConnectionString %>" 
            SelectCommand="SELECT [Image], [Title], [Description], [Bullet10], [Bullet9], [Bullet8], [Bullet7], [Bullet6], [Bullet5], [Bullet4], [Tagline], [Bullet1], [Bullet2], [Bullet3], [LeadFormsID], [DateCreated] FROM [LeadForms]">
            <InsertParameters>
                <asp:Parameter Name="Image" Type="String" />
                <asp:Parameter Name="Title" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="Bullet10" Type="String" />
                <asp:Parameter Name="Bullet9" Type="String" />
                <asp:Parameter Name="Bullet8" Type="String" />
                <asp:Parameter Name="Bullet7" Type="String" />
                <asp:Parameter Name="Bullet6" Type="String" />
                <asp:Parameter Name="Bullet5" Type="String" />
                <asp:Parameter Name="Bullet4" Type="String" />
                <asp:Parameter Name="Tagline" Type="String" />
                <asp:Parameter Name="Bullet1" Type="String" />
                <asp:Parameter Name="Bullet2" Type="String" />
                <asp:Parameter Name="Bullet3" Type="String" />
                <asp:Parameter Name="DateCreated" Type="DateTime" />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
            DataKeyNames="LeadFormsID" DataSourceID="SqlDataSource1" Height="50px" 
            Width="780px">
            <Fields>
                <asp:BoundField DataField="Image" HeaderText="Image" SortExpression="Image" />
                <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                <asp:BoundField DataField="Description" HeaderText="Description" 
                    SortExpression="Description" />
                <asp:BoundField DataField="Bullet10" HeaderText="Bullet10" 
                    SortExpression="Bullet10" />
                <asp:BoundField DataField="Bullet9" HeaderText="Bullet9" 
                    SortExpression="Bullet9" />
                <asp:BoundField DataField="Bullet8" HeaderText="Bullet8" 
                    SortExpression="Bullet8" />
                <asp:BoundField DataField="Bullet7" HeaderText="Bullet7" 
                    SortExpression="Bullet7" />
                <asp:BoundField DataField="Bullet6" HeaderText="Bullet6" 
                    SortExpression="Bullet6" />
                <asp:BoundField DataField="Bullet5" HeaderText="Bullet5" 
                    SortExpression="Bullet5" />
                <asp:BoundField DataField="Bullet4" HeaderText="Bullet4" 
                    SortExpression="Bullet4" />
                <asp:BoundField DataField="Tagline" HeaderText="Tagline" 
                    SortExpression="Tagline" />
                <asp:BoundField DataField="Bullet1" HeaderText="Bullet1" 
                    SortExpression="Bullet1" />
                <asp:BoundField DataField="Bullet2" HeaderText="Bullet2" 
                    SortExpression="Bullet2" />
                <asp:BoundField DataField="Bullet3" HeaderText="Bullet3" 
                    SortExpression="Bullet3" />
                <asp:BoundField DataField="LeadFormsID" HeaderText="LeadFormsID" 
                    InsertVisible="False" ReadOnly="True" SortExpression="LeadFormsID" />
                <asp:BoundField DataField="DateCreated" HeaderText="DateCreated" 
                    SortExpression="DateCreated" />
                <asp:CommandField ShowInsertButton="True" />
            </Fields>
        </asp:DetailsView>
    </div>
    </form>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
You need to enable inserting on the Detailsview - which will add an <InsertItemTemplate> for each field to the detailsview (it will have textboxes instead of labels).  Also if you don't want to have to click insert, there is a property on the detailsview "Defaultmode" set it's property to "Insert"

Author

Commented:
Ok, I did that, thanks.   Now I don't see a save button anywhere when the page loads.  Did I do something wrong?

Commented:
Quite possibly - should have a save and cancel button by default.  Did it give you the texts boxes at least and load into that mode automatically?

Commented:
Wait... looking at your code, you have it enabled - but it will say insert instead of save.  Do you see the insert button?

Author

Commented:
Somehow that code got removed.   After I fixed it, it worked.   Thanks!   I have a lot more questions on some basic .NET stuff.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial