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" />
<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" />
<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" />
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete" />
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False"
CommandName="New" Text="New" />
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStringsroductConnectionString %>"
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>
<asparameter Name="ID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asparameter Name="ProdNum" Type="String" />
<asparameter Name="Description" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:FormParameter FormField="FormProdNum" Name="ProdNum" Type="String" />
</SelectParameters>
<UpdateParameters>
<asparameter Name="ProdNum" Type="String" />
<asparameter Name="Description" Type="String" />
<asparameter Name="ID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</div>
</div>
</form>
Thanks so much for your help
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" />
<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" />
<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" />
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete" />
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False"
CommandName="New" Text="New" />
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStringsroductConnectionString %>"
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>
<asparameter Name="ID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asparameter Name="ProdNum" Type="String" />
<asparameter Name="Description" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:FormParameter FormField="FormProdNum" Name="ProdNum" Type="String" />
</SelectParameters>
<UpdateParameters>
<asparameter Name="ProdNum" Type="String" />
<asparameter Name="Description" Type="String" />
<asparameter Name="ID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</div>
</div>
</form>
Thanks so much for your help