[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

InsertItemTemplate question

Posted on 2011-03-01
2
Medium Priority
?
314 Views
Last Modified: 2012-05-11
I have the following code in an ASP page.   I'm just trying to get a very basic 2 field insert done, but when the page is rendered, none of the fields in the formview even show up on the page (nor in the source code).   What am I doing wrong here?
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:KartrisSQLConnection %>" 

                InsertCommand="INSERT INTO [tblDCPersonTest] ([pers_firstname], [pers_middlename], [pers_lastname], [pers_ssn], [pers_dob], [pers_phonehome], [pers_phonework], [pers_personid]) VALUES (@pers_firstname, @pers_middlename, @pers_lastname, @pers_ssn, @pers_dob, @pers_phonehome, @pers_phonework, @pers_personid)" 
>

                <InsertParameters>
                    <asp:Parameter Name="pers_firstname" Type="String" />
                    <asp:Parameter Name="pers_middlename" Type="String" />
                    <asp:Parameter Name="pers_lastname" Type="String" />
                    <asp:Parameter Name="pers_ssn" Type="String" />
                    <asp:Parameter Name="pers_dob" Type="String" />
                    <asp:Parameter Name="pers_phonehome" Type="String" />
                    <asp:Parameter Name="pers_phonework" Type="String" />
                    <asp:Parameter Name="pers_personid" Type="Object" />
                </InsertParameters>
            </asp:SqlDataSource>

                        <asp:FormView ID="FormView1" runat="server" DataSourceId="SqlDataSource1" DataKeyNames="pers_personid">
                            <InsertItemTemplate> 
                            First Name: <asp:TextBox ID="pers_firstname" runat="server" Text='<%# Bind("pers_firstname") %>'></asp:TextBox><br />
                            Last Name: <asp:TextBox ID="pers_lastname" runat="server" Text='<%# Bind("pers_lastname") %>'></asp:TextBox><br />
                            <asp:Button ID="butSubmit" runat="server" CommandName="Insert" Text="Submit" />
                            </InsertItemTemplate>
                        </asp:FormView>

Open in new window

0
Comment
Question by:saturation
2 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 2000 total points
ID: 35012313
For an insertitemtemplate to be shown the formview has to be in insert mode by default it will show only an ItemTemplate to change this add a DefaultMode attribute to the formview tag and set to INsert :

<asp:FormView ID="FormView1" runat="server" DataSourceId="SqlDataSource1" DataKeyNames="pers_personid" DefaultMode="Insert">
0
 

Author Closing Comment

by:saturation
ID: 35012408
Great!  Now I have a follow-up question about the InsertCommand and my primary key field.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question