2013-05-29 487 views
0

需要放置在sql數據庫中的我的模式表的代碼。我需要將這些文本框放入我的數據庫中,但我不確定要如何操作。我只需要從這個模式的文本框將數據導入到我的數據庫中。將數據從文本框導入到sql數據庫中

<div id="AddInfo" style="display: none;"> 
     <table> 
      <tr> 
       <td> 
        <asp:Label ID="lblId" runat="server" Text="ID" Height="16px" Width="135px"></asp:Label> 
        <asp:Label ID="lblLastName" runat="server" Text="Last Name" Height="16px" Width="129px"></asp:Label> 
        <asp:Label ID="lblFirstName" runat="server" Text="First Name" Height="16px" Width="134px"></asp:Label> 
        <asp:Label ID="lblMiddleName" runat="server" Text="Middle Name" Height="16px" Width="131px"></asp:Label> 
       </td> 
      </tr> 
      <tr> 
       <td> 
        <asp:TextBox ID="tbID" runat="server" Height="16px" Width="125px"></asp:TextBox> 
        <asp:TextBox ID="tbLastName" runat="server" Height="16px" Width="125px"></asp:TextBox> 
        <asp:TextBox ID="tbFirstName" runat="server" Height="16px" Width="125px"></asp:TextBox> 
        <asp:TextBox ID="tbMiddleName" runat="server" Height="16px" Width="125px"></asp:TextBox> 
       </td> 
      </tr> 
      <tr> 
       <td> 
        <asp:Label ID="lblTitle" runat="server" Text="Title" Height="16px" Width="134px"></asp:Label> 
        <asp:Label ID="lblSSN" runat="server" Text="SSN" Height="16px" Width="125px"></asp:Label> 
        <asp:Label ID="lblDOB" runat="server" Text="DOB" Height="16px" Width="134px"></asp:Label> 
        <asp:Label ID="lblHireDate" runat="server" Text="Hire Date" Height="16px" Width="131px"></asp:Label> 
       </td> 
      </tr> 
      <tr> 
       <td> 
        <asp:TextBox ID="tbTitle" runat="server" Height="16px" Width="125px"></asp:TextBox> 
        <asp:TextBox ID="tbSSN" runat="server" Height="16px" Width="125px"></asp:TextBox> 
        <asp:TextBox ID="tbDOB" runat="server" Height="16px" Width="125px"></asp:TextBox> 
        <asp:TextBox ID="tbHireDate" runat="server" Height="16px" Width="125px"></asp:TextBox> 
       </td> 
      </tr> 
      <tr> 
       <td> 
        <asp:Label ID="lblAddress" runat="server" Text="Address" Height="16px" Width="132px"></asp:Label> 
        <asp:Label ID="lblCity" runat="server" Text="City" Height="16px" Width="132px"></asp:Label> 
        <asp:Label ID="lblState" runat="server" Text="State" Height="16px" Width="133px"></asp:Label> 
        <asp:Label ID="lblZip" runat="server" Text="Zip" Height="16px" Width="125px"></asp:Label> 
       </td> 
      </tr> 
      <tr> 
       <td> 
        <asp:TextBox ID="tbAddress" runat="server" Height="16px" Width="125px"></asp:TextBox> 
        <asp:TextBox ID="tbCity" runat="server" Height="16px" Width="125px"></asp:TextBox> 
        <asp:TextBox ID="tbState" runat="server" Height="16px" Width="125px"></asp:TextBox> 
        <asp:TextBox ID="tbZip" runat="server" Height="16px" Width="125px"></asp:TextBox> 
       </td> 
      </tr> 
      <tr> 
       <td> 
        <br /> 
        <asp:Button ID="btnCancelNew" runat="server" Text="Cancel" Font-Size="X-Small" /> 
       </td> 
      </tr> 
     </table> 

這是我在頁面上填充gridview的sql數據庫。它只是按設施排序數據。

private void BindGrid() 
{ 
    //set up arguments for the stored proc 
    int? FacilityID = (ddlFacility2.SelectedValue.Equals("-1")) ? (int?)null : int.Parse(ddlFacility2.SelectedValue); 
    int? OtherDataID = null; 

    //bind 
    GvReportResults.DataSource = this.DataLayer.model.MS_spGetOtherData(FacilityID, OtherDataID); 
    GvReportResults.DataBind(); 
} 

private void ResetForm() 
{ 
    try 
    { 
     //facility dropdown 
     ddlFacility2.Items.Clear(); 
     ddlFacility2.DataSource = this.DataLayer.model.MS_spGetFacilityInfo(null).OrderBy(x => x.FacilityName); 
     ddlFacility2.DataTextField = "FacilityName"; 
     ddlFacility2.DataValueField = "FacilityID"; 
     ddlFacility2.DataBind(); 
     ddlFacility2.Items.Insert(0, new ListItem("All Facility Records..", "-1")); 

     BindGrid(); 

    } 
    catch (Exception ex) 
    { 
     this.SetMessage(ex.ToString(), PageMessageType.Error); 
     AISLogger.WriteException(ex); 
    } 
} 
+0

做武漢理工大學,你試過到目前爲止什麼? –

回答

相關問題