Easy Insert with ASP.NET 2.0

Using ASP.NET 2.0 makes inserting information from web user interfaces to a database a snap. Based on the 3-tier software architecture paradigm, an explanation and example of how to accomplish this task is below. The example will start with a simple data model you can use to insert the sample data. Next, there will be a proposed interface design to support the database. An example of how the ASP.NET code behind the interface can be set up to handle the data pass and lastly, a single line of code written to execute the passing of data from the ASP layer to the database.

First, construct a simple database using some ADO compatible database software such as MS SQL or Access. For the purpose of our example we will construct a model based on the following design.

Name Text
Age Integer
Gender Integer

Next, create an interface to support the data model. This example uses Visual Basic as the programming code by which the data insert operation is executed. Similar results may be accomplished using another language such as C#. A text box control is suggested for the name field. A populated drop-down list is suggested for age, and a radio button list is suggested for the gender field. Also, a button should be added for the end-user to click as a trigger to perform the actual insert.

Don’t forget to add a SQL DataSource Control; configure it to include insert capabilities in advanced mode and include all the fields from the database. An example could look like:

<form id="form1" runat="server">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:DropDownList ID="DropDownList1" runat="server">
        <asp:ListItem Text="18-25" Value="0" />
        <asp:ListItem Text="26-32" Value="1" />
        <asp:ListItem Text="33-40" Value="2" />
    <asp:RadioButtonList ID="RadioButtonList1" runat="server">
        <asp:ListItem Text="Male" Value="0"></asp:ListItem>
        <asp:ListItem Text="Female" Value="1"></asp:ListItem>

Now, in the ASP.NET interface layer, assign the appropriate parameters to the appropriate fields.

<asp:SqlDataSource ID="SqlDataSource1" runat="server">
        <asp:ControlParameter Name="Name" ControlID="TextBox1"
            PropertyName="Text" Type="Char" />
        <asp:ControlParameter Name="Age" ControlID="DropDownList1"
            PropertyName="SelectedValue" Type="Int32" />
        <asp:ControlParameter Name="Gender" ControlID="RadioButtonList1"
            PropertyName="SelectedValue" Type="Int32" />

This code observes the contents of the controls named in the ControlID tags and points them in the direction of the database’s ControlParameter Name which specifies where in the database the information should go. Of course, data types are specified in Type and PropertyName is the control property from which the information should be extracted.

Now, here comes the fun part – a single line of Visual Basic to handle the pass from ASP.NET to the database. Simply double-click the button created in the user-interface, and add this line:


If all went as intended, the project executes and the user should be able to type in their name to the text box on the interface, select their age from the drop down list, select their gender from the radio buttons, click to submit and (voila!) the information is inserted into the database build from the initial data model.

This is one example of how more advanced versions of ASP.NET reduce development time. The ease with which data-driven applications may be constructed using these tools and supporting technologies is a testament to rapid application development techniques as they are applied to the web.

Custom Software Development and Your Business – Part 1

Interested in understanding how Custom Software can help your business?

This is the first of a 2-part series on Custom Software Development and how it can dramatically improve your business.
The flexibility and control of a custom solution provides an improved ability to manage and operate your entire organization.  In addition, many organizations experience increased employee productivity and therefore, improved customer service. Read below to find out more about how custom software can improve your business or contact us today to discuss your specific operational challenges.

Continue reading “Custom Software Development and Your Business – Part 1”

Paypal Buttons with ASP.NET Custom Controls

Introduction: Paypal Buttons and ASP.NET

Example Paypal Button



Paypal is a popular payment gateway service used by many small businesses and individuals to accept payments online.  The Paypal Website Payments Standard service provides you with an interface to create customized Paypal buttons.  When a customer clicks on button, they will be directed to a Paypal checkout page for a particular good or service.  After you create a button, you are presented with some automatically generated HTML code.  You can copy and paste this generated code into any web page’s source code to display the button.

Example PayPalDropDown

Unfortunately for ASP.NET developers, the generated HTML button does not work in an ASP.NET web form.  Paypal’s code conflicts with the <form action=’…’ method=’post’> tag that surrounds every ASP.NET web form.  When the Paypal code is inserted into an .aspx markup file, the button does nothing but refresh the page when it is clicked.

The PayPalControls Library

To solve this problem, we created the PayPalControls custom ASP.NET server control library.  The library includes two controls: PayPalButton and PayPalDropDown.  Both controls function just like a normal ASP.NET web forms toolbox control (e.g. <asp:ImageButton />). Continue reading “Paypal Buttons with ASP.NET Custom Controls”