Databinding in InsertItemTemplate of FormView

S

Swetha

Hello

I have a FormView with InsertItem, EditItem and ItemTemplates.
Depending on from where the page is accessed, the page opens up in
either Insert, Edit or ReadOnly mode. The FormView is databound. The
problem I have is when the page opens up in Insert Mode. I require one
of the fields to be populated with a databound field, but for some some
reason this doesnt happen in the InsertMode.

Following is the FormView:

<asp:FormView ID="FormView1" runat="server"
DataSourceID="SqlDataSource1" >
<EditItemTemplate>
Client Name:
<asp:Label ID="nameLabel" runat="server" Text='<%#
Bind("name") %>'></asp:Label><br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update"></asp:LinkButton
</EditItemTemplate>
<InsertItemTemplate>
Client Name:
<asp:Label ID="nameLabel" runat="server" Text='<%#
Bind("name") %>'></asp:Label><br />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert"></asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
Client Name:
<asp:Label ID="nameLabel" runat="server" Text='<%#
Bind("name") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server"
CommandName="Edit" Text="Modify"></asp:LinkButton>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:plus32ConnectionString %>"
InsertCommand="addNew" InsertCommandType="StoredProcedure"
SelectCommand="select clientID, name where packageID = @packageID">
<SelectParameters>
<asp:QueryStringParameter Name="packageID"
QueryStringField="packageID" Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:parameter Name="clientID" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>

The binding in the InsertItemTemplate does not happen. Can someone
explain why this is happening? And how can I work around this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,795
Messages
2,569,644
Members
45,358
Latest member
TreyTritt8

Latest Threads

Top