一个页面只能有一个服务器端的Form标签。(如何在主页面中添加多个表单)

时间:2017-04-10 15:36:10

标签: asp.net master-pages

您好我在我的主页面中使用表单,因为我想从数据库表中显示一个下拉菜单,这里是我的代码

<body>
      <form id="form1"  runat="server">
        <div class="container-fluid">
            <nav class="navbar navbar-default">
                <div class="navbar-header">
                    <div class="navbar-brand logo">
                         <a href="home.aspx"><span>Ads</span>Valley</a>
                    </div>
                </div>
                <div class="collapse navbar-collapse">
                    <asp:DropDownList runat="server" ID="DropDownCity" CssClass="DropDownCity" >
                    </asp:DropDownList>
                    <asp:DropDownList runat="server" ID="DropDownCountry" CssClass="DropDownCity">
                    </asp:DropDownList>
                    <asp:DropDownList runat="server" ID="DropDownCate" CssClass="DropDownCity">
                    </asp:DropDownList>
                      <asp:HyperLink ID="Pending" NavigateUrl="~/Requests.aspx" runat="server" CssClass="PendingReq">Pending Request<asp:Label runat="server" ID="Spam" CssClass="badge"></asp:Label></asp:HyperLink>
                    <asp:HyperLink ID="ButtonLogout" runat="server" CssClass="Adminlogout" NavigateUrl="~/Logout.aspx">Logout</asp:HyperLink> 
                </div  
            </nav>
        </div>
        <div class="main-banner banner text-center">
        <div class="container">
            <h1>Sell <span class="segment-heading">Anything Online For Free </span>With AdsValley</h1>
            <h3><strong><span class="auto-style2">Welcome Admin</span></strong></h3>
            <p>
                &nbsp;</p>

        </div>
    </div>
           </form>       
    <asp:ContentPlaceHolder id="head" runat="server"></asp:ContentPlaceHolder>
        <asp:ContentPlaceHolder id="Content" runat="server"></asp:ContentPlaceHolder>
       <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
 </asp:ContentPlaceHolder>   
</body>
</html>

现在我想在子页面中使用另一个表单,因为我想使用网格视图从数据库表中显示我的页面上的数据但是我遇到了这个错误 &#34;一个页面只能有一个服务器端的Form标签。&#34;什么可能的解决方案,你能指导我吗? 这是子页面// requests.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Admin_MasterPage.master" AutoEventWireup="true" CodeFile="Requests.aspx.cs" Inherits="Requests" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <form id="form1" runat="server">
   <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="AdsId" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
   <Columns>
            <asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="150" />
            <asp:BoundField DataField="Cat_ID" HeaderText="Category ID" ItemStyle-Width="150" />
            <asp:BoundField DataField="Ad_Title" HeaderText="Ads Title" ItemStyle-Width="150" />
             <asp:BoundField DataField="Brand" HeaderText="Brand" ItemStyle-Width="150" />
            <asp:BoundField DataField="Model" HeaderText="Model" ItemStyle-Width="150" />
            <asp:BoundField DataField="Price" HeaderText="Price" ItemStyle-Width="150" />
            <asp:BoundField DataField="Description" HeaderText="Description" ItemStyle-Width="150" />
            <asp:BoundField DataField="Conditions" HeaderText="Conditions" ItemStyle-Width="150" />
           <asp:BoundField DataField="Owner" HeaderText="Owner" ItemStyle-Width="150" />
           <asp:BoundField DataField="Contact" HeaderText="Contact" ItemStyle-Width="150" />
           <asp:BoundField DataField="City" HeaderText="City" ItemStyle-Width="150" />
           <asp:BoundField DataField="Date" HeaderText="Date" ItemStyle-Width="150" />
          <asp:BoundField DataField="ImageName" HeaderText="Image Name" ItemStyle-Width="150" />
            <asp:BoundField DataField="ImageContent" HeaderText="Image Content" ItemStyle-Width="150" />
           <asp:BoundField DataField="Photo1" HeaderText="Photo 1" ItemStyle-Width="150" />
           <asp:BoundField DataField="Photo2" HeaderText="Photo 2" ItemStyle-Width="150" />
           <asp:BoundField DataField="Photo3" HeaderText="Photo 3" ItemStyle-Width="150" />
        <asp:CommandField ButtonType="Link" ShowEditButton="true" ShowDeleteButton="true"
                ItemStyle-Width="100" />
       <asp:CommandField  ButtonType="Link" EditText="Accept" ShowEditButton="true"/>
        </Columns>
         </asp:GridView>
     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:dbconnection %>"
          SelectCommand="SELECT [Country], [Cat_ID], [Ad_Title], [Brand], [Model], [Price], [Description], [Owner], [ImageName], [ImageContent], [Photo1], [Contact], [City], [Date], [Owner_ID], [Conditions], [Photo2], [Photo3] FROM [Ads]" UpdateCommand="UPDATE Ads SET Country = @Country, Cat_ID = @catId, Ad_Title=@tite, Brand=@brand, Model=@mod, Price=@prc, Description=@des, Conditions=@cond, Owner=@own, Contact=@cont, City=@City, Date=@d, ImageName=@imgn, ImageContent=@imgCot, Photo1=@ph1, Photo2=@ph2, Photo3=@ph3 WHERE AdsId = @AdsId"
        DeleteCommand="DELETE FROM Country WHERE AdsId = @AdsId">
       <%-- define paramerters here--%>
         <UpdateParameters>
             <asp:Parameter Name="AdsId" Type="Int32" />
             <asp:Parameter Name="Country" Type="String" />
             <asp:Parameter  Name="catId" Type="Int32"/>
             <asp:Parameter Name="title" Type="String" />
             <asp:Parameter Name="brand" Type="String" />
             <asp:Parameter Name="mod" Type="String" />
             <asp:Parameter Name="prc" Type="Int32" />
             <asp:Parameter Name="des" Type="String" />
              <asp:Parameter Name="cond" Type="String" />
             <asp:Parameter Name="own" Type="String" />
             <asp:Parameter Name="cont" Type="String" />
             <asp:Parameter Name="city" Type="String" />
             <asp:Parameter Name="d" Type="DateTime" />
             <asp:Parameter Name="imgn" Type="String" />
             <asp:Parameter Name="imgCot" Type="String" />
             <asp:Parameter Name="ph1" Type="String"/>
             <asp:Parameter Name="ph2" Type="String"/>
             <asp:Parameter Name="ph3" Type="String"/>
         </UpdateParameters>
         <DeleteParameters>
             <asp:Parameter Name="AdsId" Type="Int32" />
         </DeleteParameters>
     </asp:SqlDataSource>   
 </form>
</asp:Content>

0 个答案:

没有答案