<%@ Page Title=""  Language="C#"   AutoEventWireup="true"   %>


<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
    <title>设定问题选项</title>
    <link href="css/main.css" rel="stylesheet" type="text/css" />
</head>
<body style=" margin:30px; overflow:hidden; width:800px; height:500px;" >
    <form id="form1" runat="server">

   请添加问题选择（适用于单选框、复兴框、下拉框、分组选项的选项）
 
      <asp:GridView ID="GridView2" runat="server" ShowHeader="false" AutoGenerateColumns="False"  BorderWidth="0"
            DataSourceID="SqlDataSource2"  Width="500px">
            <Columns>
          
                    
                    <asp:TemplateField>
                    <ItemTemplate>
                      <b><%#Eval("subject")%></b>
                    </ItemTemplate>
                    
                    </asp:TemplateField>
            </Columns>
        </asp:GridView>
        
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT [subject] FROM [survery_subjects] WHERE ([id] = @id and activeid=@activeid)">
            
            
            <SelectParameters>
                <asp:QueryStringParameter Name="id" QueryStringField="id" Type="Int32" />
                 <asp:QueryStringParameter Type="Int32" Name="activeid" QueryStringField="activeid" />
            </SelectParameters>
        </asp:SqlDataSource>
 
     
  
        <asp:FormView ID="FormView1" runat="server" DataKeyNames="itemid"  Width="500px"
            DataSourceID="SqlDataSource1" DefaultMode="Insert">
            
            <InsertItemTemplate>
                
     设定选项:  <asp:TextBox ID="itemTextBox" ValidationGroup="add"   Width="200" runat="server" Text='<%# Bind("item") %>' />
                <asp:RequiredFieldValidator ValidationGroup="add"   ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ForeColor="Red" ControlToValidate="itemTextBox"></asp:RequiredFieldValidator>
                <asp:Button ID="InsertButton" runat="server" CausesValidation="True" 
               ValidationGroup="add"       CommandName="Insert" Text="添加"  />
            
            </InsertItemTemplate>
           
        </asp:FormView>
   
   
   
    
   
   
   
   
   <div style=" margin-top:20px;">
   
        <asp:GridView ID="GridView1" SkinID="gridviewSkin" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="itemid" Width="500px" DataSourceID="SqlDataSource1"  GridLines="Both" 
            >
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ItemStyle-Width="90px" />
                <asp:BoundField DataField="itemid" HeaderText="itemid" Visible="false" ReadOnly="True" 
                    SortExpression="itemid" InsertVisible="False" />
                <asp:BoundField DataField="id" HeaderText="id" Visible="false" SortExpression="id" />
                <asp:BoundField DataField="item" HeaderText="item" SortExpression="item" />
            </Columns>
        </asp:GridView>
     </div>   
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            DeleteCommand="DELETE FROM [survery_options] WHERE [itemid] = @itemid" 
            InsertCommand="INSERT INTO [survery_options] ([id], [item],activeid) VALUES (@id, @item,@activeid)" 
           
            SelectCommand="SELECT [itemid], [id], [item] FROM [survery_options] where id=@id and activeid=@activeid" 
            
            UpdateCommand="UPDATE [survery_options] set  [item] = @item WHERE [itemid] = @itemid and activeid=@activeid ">
            <DeleteParameters>
                <asp:Parameter Name="itemid" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
               <asp:QueryStringParameter Type="Int32" Name="id" QueryStringField="id" />
                <asp:QueryStringParameter Type="Int32" Name="activeid" QueryStringField="activeid" />
                <asp:Parameter Name="item" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="item" Type="String" />
                <asp:Parameter Name="itemid" Type="Int32" />
                  <asp:QueryStringParameter Type="Int32" Name="activeid" QueryStringField="activeid" />
            </UpdateParameters>
            <SelectParameters>
            <asp:QueryStringParameter Type="Int32" Name="id" QueryStringField="id" />
              <asp:QueryStringParameter Type="Int32" Name="activeid" QueryStringField="activeid" />
            </SelectParameters>
        </asp:SqlDataSource>
    


</form>
</body>
</html>

 