Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FormView Insert Update and Delete not showing

Status
Not open for further replies.

mana2

Programmer
Aug 9, 2002
116
US
Hi,

I have 2 pages. The first has a formfield that gets an input from the user and the second page displays the results. I'm using the FormView item from the toolbox in Visual Web Developer and the Edit, Insert and Delete options don't show up. No matter what I use in the Selectparameter, form or control, the options don't show up. If I hardcode the value in the select statement and with no selectparameters, Edit/Insert/Delete options show up. If I use a variable in the select statement, it doesn't work:


SelectCommand="SELECT * from FROM [Product] where prodnum='2000'"

Page1:

<form id="form1" runat="server">

<asp:Label id="lblProdNum" runat="server" Text="ProdNum "></asp:Label>
<asp:TextBox id="FormProdNum" runat="server"></asp:TextBox>
<asp:Button runat="server" Text="Search" id="Button1" PostBackUrl="Results.aspx"></asp:Button>

Page 2- Results.aspx:

<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID"
DataSourceID="SqlDataSource1">
<EditItemTemplate>
ID:
<asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
<br />
ProdNum:
<asp:TextBox ID="ProdNumTextBox" runat="server" Text='<%# Bind("ProdNum") %>' />
<br />
Description:
<asp:TextBox ID="DescriptionTextBox" runat="server"
Text='<%# Bind("Description") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
&nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
ProdNum:
<asp:TextBox ID="ProdNumTextBox" runat="server" Text='<%# Bind("ProdNum") %>' />
<br />
Description:
<asp:TextBox ID="DescriptionTextBox" runat="server"
Text='<%# Bind("Description") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
&nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
ID:
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
<br />
ProdNum:
<asp:Label ID="ProdNumLabel" runat="server" Text='<%# Bind("ProdNum") %>' />
<br />
Description:
<asp:Label ID="DescriptionLabel" runat="server"
Text='<%# Bind("Description") %>' />
<br />

<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit" />
&nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete" />
&nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False"
CommandName="New" Text="New" />

</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:productConnectionString %>"

SelectCommand="SELECT [ID], [ProdNum], [Description] FROM [Product] WHERE ([ProdNum] = @ProdNum)"
DeleteCommand="DELETE FROM [Product] WHERE [ID] = @ID"
InsertCommand="INSERT INTO [Product] ([ProdNum], [Description]) VALUES (@ProdNum, @Description)"


UpdateCommand="UPDATE [Product] SET [ProdNum] = @ProdNum, [Description] = @Description WHERE [ID] = @ID">
<DeleteParameters>
<asp:parameter Name="ID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:parameter Name="ProdNum" Type="String" />
<asp:parameter Name="Description" Type="String" />
</InsertParameters>

<SelectParameters>
<asp:FormParameter FormField="FormProdNum" Name="ProdNum" Type="String" />
</SelectParameters>

<UpdateParameters>
<asp:parameter Name="ProdNum" Type="String" />
<asp:parameter Name="Description" Type="String" />
<asp:parameter Name="ID" Type="Int32" />
</UpdateParameters>

</asp:SqlDataSource>

</div>
</div>

</form>


Thanks so much for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top