mardi 25 mai 2021

Web Form to SQL table

I've created a web form table that i need to feed into an SQL Table but i'm not sure where to go next, this is my first go at coding something and its basically been learning by doing but i can't get it to add submitted data to the SQL Table.

this is what i have done so far, essentially when they press the submit button i want it to take the data entered and put it into an existing SQL Table:

<%@ Page Language="C#" AutoEventWireup="true"  %>  
      
    <!DOCTYPE html>
    <script runat="server">
    
    
        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
    
        }
    
        protected void Unnamed5_Click(object sender, EventArgs e)
        {
    
        }
    </script>
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
        <title></title>  
        <style type="text/css">
            .auto-style1 {
                height: 35px;
            }
            .auto-style2 {
                height: 67px;
            }
        </style>
    </head>  
    <body>  
        <form id="form1" action="info.php" runat="server" method="post">  
            
            <div>  
                <table class="auto-style1">  
                    <tr>  
                        <td>Report Number :</td>  
                        <td>  
                            <asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>  
                        </td>  
      
                   </tr> 
                    
                    <tr>  
                        <td>Finding Number</td>  
                         <td> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></tdReport Number :</td>  
                        <td>  
                            <asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>  
                        </td>  
      
                   </tr> 
                    
                    <tr>  
                        <td>Finding Number</td>  
                         <td> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>  
                    </tr>  
                    
                    <tr>  
                        <td>Finding Category</td>  
                        <td>  
                            <asp:DropDownList ID="DropDownList1" runat="server" ViewStateMode="Disabled" DataSourceID="SqlDataSource2" DataTextField="Category" DataValueField="Category" Height="16px" Width="209px">  
                                
                            </asp:DropDownList>  
                            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NonConformity Database CR2464 AmendmentConnectionString %>" SelectCommand="SELECT [Category] FROM [NCR Category]"></asp:SqlDataSource>
                        </td>  
                    </tr>  
                    <tr>  
                        <td>Management System Element</td>  
                        <td>  
                            <asp:dropdownlist id="DropDownList2" runat="server"  ViewStateMode="Disabled" DataSourceID="SqlDataSource1" DataTextField="Quality_System_Element" DataValueField="Quality_System_Element" Height="16px" Width="562px">
                               
                            </asp:dropdownlist>  
    
                            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NonConformity Database CR2464 AmendmentConnectionString %>" SelectCommand="SELECT [Quality System Element] AS Quality_System_Element FROM [Quality System Element]"></asp:SqlDataSource>
    
                        </td>  
                   </tr>  
                    <tr>  
                        <td>Finding Description</td>  
                        <td>  
                            <asp:TextBox ID="TextBox4" runat="server" Height="53px" Width="555px"></asp:TextBox>  
                        </td>  
                    </tr> 
                    <tr>
                        <td>Action Agreed</td>
                        <td>
                            <asp:TextBox ID="ActionAgreed" runat="server" Height="115px" Width="555px"></asp:TextBox>
                        </td>
                        </tr>
                       <tr>
                           <td> Actioned to</td>
                           <td>
                               <asp:DropDownList runat="server" DataSourceID="SqlDataSource3" DataTextField="Full_Name" DataValueField="Full_Name"></asp:DropDownList>
    
    
                               <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:NonConformity Database CR2464 AmendmentConnectionString %>" SelectCommand="SELECT [Full Name] AS Full_Name FROM [Initiator]"></asp:SqlDataSource>
    
    
                           </td>
    
    
    
                       </tr>
                    <tr>
                        <td>Due Date</td>
                        <td>
                            <asp:TextBox runat="server" id="textbox5"  TextMode="Date" Readonly="false"></asp:TextBox>
    
                        </td>
    
    
                    </tr>
                    <tr>
                        <td> Actions/Progress Closure Notes</td>
                        <td>
                            <asp:TextBox ID="textbox6" runat="server" Height="54px" Width="247px"></asp:TextBox>
                        </td>
    
                    </tr>
                    <tr>
                        <td class="auto-style2">Root Cause (Enter Per Closure</td>
                        <td class="auto-style2">
    
                            <asp:DropDownList runat="server" DataSourceID="SqlDataSource4" DataTextField="Category" DataValueField="Category"></asp:DropDownList>
    
                            <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:NonConformity Database CR2464 AmendmentConnectionString %>" SelectCommand="SELECT [Category] FROM [Root Causes Table]"></asp:SqlDataSource>
    
                        </td>
                    </tr>
                    <tr>
    
                        <td>Root Cause Sub Category (Enter Post Closure</td>
                        <td>
                            <asp:DropDownList runat="server" DataSourceID="SqlDataSource5" DataTextField="Sub_Category" DataValueField="Sub_Category"></asp:DropDownList>
    
                            <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:NonConformity Database CR2464 AmendmentConnectionString %>" SelectCommand="SELECT [Sub Category] AS Sub_Category FROM [Root Causes Subcategory Table]"></asp:SqlDataSource>
    
                        </td>
    
                    </tr>
                    <tr>
    
                        <td>Date Completed</td>
                        <td>
                            <asp:TextBox runat="server"></asp:TextBox>
    
                        </td>
    
                    </tr>
                    <tr>
                        <td>
                            <asp:Button runat="server" Text="Submit" inputtype="Submit" OnClick="Unnamed5_Click" />
    
                        </td>
    
                    </tr>
                </table>  
            </div>  
        </form>  
    </body>  
    </html>  



Aucun commentaire:

Enregistrer un commentaire