title: Making changes to a database entry in visual studio
body: <p>I'm building a web app that displays database information from a table of gym equipment.  So far, I am able to produce a webpage, with a dropdown list of all the items, and the information auto-populates the fields for information.</p>
  
  <p>How do I make it so somebody viewing the website can add, delete, and modify table entries with just a few buttons like add/update/delete/submit?</p>
  
  <p>Here is the C# code I have produced so far:</p>
  
  <pre><code>public partial class Inventory : System.Web.UI.Page
  {
  Item currentInventory = new Item();
  
  protected void Page_Load(object sender, EventArgs e)
  {
      UpdateInventory(0);
  }
  
  
  
  private void UpdateInventory(int index)
  {
      DataView inventoryTable = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
      DataRowView row = (DataRowView)inventoryTable[index];
  
      currentInventory.fac_ID = row["fac_ID"].ToString();
      currentInventory.inv_Quantity = row["inv_Quantity"].ToString();
      currentInventory.inv_Purchase_Date = row["inv_Purchase_Date"].ToString();
  
  
      lblFacilityID.Text = currentInventory.fac_ID;
      lblQuantity.Text = currentInventory.inv_Quantity;
      lblPurchaseDate.Text
  = Convert.ToDateTime(row["inv_Purchase_Date"]).ToShortDateString();
  }
  
  protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  {
      UpdateInventory(DropDownList1.SelectedIndex);
  }
  }
  </code></pre>
  
  <p>And here is the .aspx code I have so far:</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"    CodeFile="Inventory.aspx.cs" Inherits="Inventory" %&gt;
  
   &lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server"&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="Server"&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="Server"&gt;
  &lt;asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"   DataTextField="equip_Name" DataValueField="equip_ID" AutoPostBack="True"   OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"&gt;
  &lt;/asp:DropDownList&gt;
   &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="    &lt;%$      ConnectionStrings:ConnectionString %&gt;" SelectCommand="SELECT Inventory.*, Equipment.* FROM      Equipment INNER JOIN Inventory ON Equipment.equip_ID = Inventory.equip_ID"&gt;   &lt;/asp:SqlDataSource&gt;
  
  &lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;Facility:
          &lt;/td&gt;
          &lt;td&gt;
              &lt;asp:Label ID="lblFacilityID" runat="server"&gt;&lt;/asp:Label&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Quantity:
          &lt;/td&gt;
          &lt;td&gt;
              &lt;asp:Label ID="lblQuantity" runat="server"&gt;&lt;/asp:Label&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Purchase Date:
          &lt;/td&gt;
          &lt;td&gt;
              &lt;asp:Label ID="lblPurchaseDate" runat="server"&gt;&lt;/asp:Label&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;br /&gt;
  &lt;asp:DetailsView ID="ManageProducts" runat="server" Height="50px" Width="125px"&gt;
  &lt;/asp:DetailsView&gt;
  
  
  &lt;/asp:Content&gt;
  </code></pre>