By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,647 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,647 IT Pros & Developers. It's quick & easy.

VWD 2008 - Need help programming submit button

P: 49
Good Day! I am fairly new to asp.net. I am using Microsoft VWD 2008 express edition. I have linked an Access 2007 database to my asp.net application using a gridview control. On the webpage are four text boxes allowing a user to input (first name, last name, donation amount and date).

After the user inputs the values, I want them to click the "Submit" button and have that information from the text boxes write to the Access 2007 database.

This is where my problem lies. I hit a blank when I begin to program the button. Not sure where to start. Any help is appreciated! Thanks. ~Mike

My code is below:

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head runat="server">
  7.     <title></title>
  8. </head>
  9. <body>
  10.     <form id="form1" runat="server">
  11.     <p>
  12.         First Name:&nbsp;
  13.         <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
  14.     </p>
  15.     <p>
  16.         &nbsp;</p>
  17.     <p>
  18.         Last Name:&nbsp;
  19.         <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
  20.     </p>
  21.     <p>
  22.         &nbsp;</p>
  23.     <p>
  24.         Donation:&nbsp;
  25.         <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
  26.     </p>
  27.     <p>
  28.         &nbsp;</p>
  29.     <p>
  30.         Donation Date:&nbsp;
  31.         <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
  32.     </p>
  33.     <p>
  34.         &nbsp;</p>
  35.     <p>
  36.         <asp:Button ID="btnSubmit" runat="server" Text="Submit" style="height: 26px" />
  37.     </p>
  38.     <p>
  39.         &nbsp;</p>
  40.     <p>
  41.         <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
  42.             ConflictDetection="CompareAllValues" 
  43.             ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
  44.             DeleteCommand="DELETE FROM [Table1] WHERE (([Last Name] = ?) OR ([Last Name] IS NULL AND ? IS NULL)) AND [ID] = ? AND (([First Name] = ?) OR ([First Name] IS NULL AND ? IS NULL)) AND (([Donation Amount] = ?) OR ([Donation Amount] IS NULL AND ? IS NULL)) AND (([Date of Donation] = ?) OR ([Date of Donation] IS NULL AND ? IS NULL))" 
  45.             InsertCommand="INSERT INTO [Table1] ([ID], [First Name], [Last Name], [Donation Amount], [Date of Donation]) VALUES (?, ?, ?, ?, ?)" 
  46.             OldValuesParameterFormatString="original_{0}" 
  47.             ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
  48.             SelectCommand="SELECT * FROM [Table1]" 
  49.             UpdateCommand="UPDATE [Table1] SET [ID] = ?, [First Name] = ?, [Donation Amount] = ?, [Date of Donation] = ? WHERE (([Last Name] = ?) OR ([Last Name] IS NULL AND ? IS NULL)) AND [ID] = ? AND (([First Name] = ?) OR ([First Name] IS NULL AND ? IS NULL)) AND (([Donation Amount] = ?) OR ([Donation Amount] IS NULL AND ? IS NULL)) AND (([Date of Donation] = ?) OR ([Date of Donation] IS NULL AND ? IS NULL))">
  50.             <DeleteParameters>
  51.                 <asp:Parameter Name="original_Last_Name" Type="String" />
  52.                 <asp:Parameter Name="original_ID" Type="Int32" />
  53.                 <asp:Parameter Name="original_First_Name" Type="String" />
  54.                 <asp:Parameter Name="original_Donation_Amount" Type="Decimal" />
  55.                 <asp:Parameter Name="original_Date_of_Donation" Type="DateTime" />
  56.             </DeleteParameters>
  57.             <UpdateParameters>
  58.                 <asp:Parameter Name="ID" Type="Int32" />
  59.                 <asp:Parameter Name="First_Name" Type="String" />
  60.                 <asp:Parameter Name="Donation_Amount" Type="Decimal" />
  61.                 <asp:Parameter Name="Date_of_Donation" Type="DateTime" />
  62.                 <asp:Parameter Name="original_Last_Name" Type="String" />
  63.                 <asp:Parameter Name="original_ID" Type="Int32" />
  64.                 <asp:Parameter Name="original_First_Name" Type="String" />
  65.                 <asp:Parameter Name="original_Donation_Amount" Type="Decimal" />
  66.                 <asp:Parameter Name="original_Date_of_Donation" Type="DateTime" />
  67.             </UpdateParameters>
  68.             <InsertParameters>
  69.                 <asp:Parameter Name="ID" Type="Int32" />
  70.                 <asp:Parameter Name="First_Name" Type="String" />
  71.                 <asp:Parameter Name="Last_Name" Type="String" />
  72.                 <asp:Parameter Name="Donation_Amount" Type="Decimal" />
  73.                 <asp:Parameter Name="Date_of_Donation" Type="DateTime" />
  74.             </InsertParameters>
  75.         </asp:SqlDataSource>
  76.     </p>
  77.     <p>
  78.         <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
  79.             DataKeyNames="Last Name" DataSourceID="SqlDataSource1">
  80.             <Columns>
  81.                 <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
  82.                     SortExpression="ID" />
  83.                 <asp:BoundField DataField="First Name" HeaderText="First Name" 
  84.                     SortExpression="First Name" />
  85.                 <asp:BoundField DataField="Last Name" HeaderText="Last Name" ReadOnly="True" 
  86.                     SortExpression="Last Name" />
  87.                 <asp:BoundField DataField="Donation Amount" HeaderText="Donation Amount" 
  88.                     SortExpression="Donation Amount" />
  89.                 <asp:BoundField DataField="Date of Donation" HeaderText="Date of Donation" 
  90.                     SortExpression="Date of Donation" />
  91.             </Columns>
  92.         </asp:GridView>
  93.     </p>
  94.     <p>
  95.         &nbsp;</p>
  96.     <p>
  97.         &nbsp;</p>
  98.     <div>
  99.  
  100.     </div>
  101.     </form>
  102. </body>
  103. </html>
Sep 23 '08 #1
Share this Question
Share on Google+
2 Replies


kenobewan
Expert 2.5K+
P: 4,871
You need to use the click event of the button to open a connection to your DB and insert the values. Suggest search the site for an example.
Sep 26 '08 #2

P: 49
I got it figured out, Thanks!
Sep 28 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.