hi there,
i am coming up with a form. i have to insert data into the sql database. i am able to do that. The problem is that, when i insert, the data i entered one shows twice in the table. i just click once and there are the same data showing twice. I encountered this after including the dropdownlist. please help me. i am short of time.

This is my code in visual studio form. i used a sql insert statement, as below:

ALTER Procedure [dbo].[Insert_StaffRegis_Table]

@StaffID varchar(50),
@FirstName varchar(50),
@LastName varchar(50), 
@Password varchar(50), 
@RetypePass varchar(50), 
@Designation char(1), 
@Gender varchar(50), 
@DOB varchar(50), 
@Department varchar(50), 
@SecretQues varchar(50), 
@SecretAns varchar(50)

As

Insert into StaffRegis_Table (StaffID,FirstName,LastName,Password,RetypePass,Designation,Gender,DOB,Department,SecretQues,SecretAns)
values  (@StaffID,@FirstName,@LastName,@Password,@RetypePass,@Designation,@Gender,@DOB,@Department,@SecretQues,@SecretAns)
Return


<script runat="server">
    Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        SqlDataSource1.Insert()


    End Sub


    Protected Sub SqlDataSource1_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Inserting
        e.Command.Parameters("@StaffID").Value = TextBox1.Text
        e.Command.Parameters("@FirstName").Value = TextBox2.Text
        e.Command.Parameters("@LastName").Value = TextBox3.Text
        e.Command.Parameters("@Password").Value = TextBox4.Text
        e.Command.Parameters("@RetypePass").Value = TextBox5.Text
        e.Command.Parameters("@Designation").Value = DropDownList3.SelectedValue
        e.Command.Parameters("@Gender").Value = DropDownList2.SelectedValue
        e.Command.Parameters("@DOB").Value = TextBox8.Text
        e.Command.Parameters("@Department").Value = TextBox9.Text
        e.Command.Parameters("@SecretQues").Value = DropDownList1.SelectedValue
        e.Command.Parameters("@SecretAns").Value = TextBox10.Text

    End Sub

    Protected Sub DropDownList3_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
        .style1
        {
            height: 40px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<table border="0" cellpadding="0">
<tr>
<th>
    <asp:Label ID="Label1" runat="server" Text="ID"></asp:Label></th>
<td align="left">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
        ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox1">*</asp:RequiredFieldValidator>
    </td>

</tr>

<tr>
<th>
    <asp:Label ID="Label2" runat="server" Text="First Name"></asp:Label></th>
<td align="left">
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
        ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox2">*</asp:RequiredFieldValidator>
    </td>

</tr>

<tr>
<th>
    <asp:Label ID="Label3" runat="server" Text="Last Name"></asp:Label></th>
<td align="left">
    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
        ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox3">*</asp:RequiredFieldValidator>
    </td>

</tr>


<tr>
<th>
    <asp:Label ID="Label4" runat="server" Text="Password"></asp:Label></th>
<td align="left">
    <asp:TextBox ID="TextBox4" runat="server" TextMode="Password"></asp:TextBox>
    <asp:CompareValidator ID="CompareValidator1" runat="server" 
        ErrorMessage="CompareValidator" ControlToValidate="TextBox5" ControlToCompare="TextBox4">*</asp:CompareValidator>
    </td>

</tr>


<tr>
<th>
    <asp:Label ID="Label5" runat="server" Text="Retype Password"></asp:Label></th>
<td align="left">
    <asp:TextBox ID="TextBox5" runat="server" TextMode="Password"></asp:TextBox>&nbsp;&nbsp;
    <asp:Label ID="Label11" runat="server" Text="Label"></asp:Label>
    </td>

</tr>

<tr>
<th>
    <asp:Label ID="Label6" runat="server" Text="Designation"></asp:Label></th>
<td align="left">

    <asp:DropDownList ID="DropDownList3" runat="server" Width="150px" 
        onselectedindexchanged="DropDownList3_SelectedIndexChanged" >
    <asp:ListItem Value="M">Manager</asp:ListItem>
    <asp:ListItem Value="D">Delivery Boy</asp:ListItem>

    </asp:DropDownList>

    &nbsp;&nbsp;&nbsp;

    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
        ErrorMessage="RequiredFieldValidator" ControlToValidate="DropDownList3">*</asp:RequiredFieldValidator>

    </td>

</tr>

<tr>
<th>
    <asp:Label ID="Label7" runat="server" Text="Gender"></asp:Label></th>
<td align="left">
    <asp:DropDownList ID="DropDownList2" runat="server" Width="150px" >
        <asp:ListItem Value="Female">Female</asp:ListItem>
        <asp:ListItem Value="Male">Male</asp:ListItem>
    </asp:DropDownList>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
        ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox2">*</asp:RequiredFieldValidator>
    </td>

</tr>

<tr>
<th>
    <asp:Label ID="Label8" runat="server" Text="D.O.B"></asp:Label></th>
<td align="left">
    <asp:TextBox ID="TextBox8" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
        ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox8">*</asp:RequiredFieldValidator>
    </td>

</tr>

<tr>
<th>
    <asp:Label ID="Label9" runat="server" Text="Department"></asp:Label></th>
<td align="left">
    <asp:TextBox ID="TextBox9" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" 
        ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox9">*</asp:RequiredFieldValidator>
    </td>

</tr>

<tr>
<th class="style1">
    <asp:Label ID="Label10" runat="server" Text="Secret Question"></asp:Label></th>
<td align="left" class="style1">
    <asp:DropDownList ID="DropDownList1" runat="server" Width="150px" 
        Height="32px" >
        <asp:ListItem>What is your hobby?</asp:ListItem>
        <asp:ListItem>where can we go?</asp:ListItem>
        <asp:ListItem>What is your mother&#39;s name?</asp:ListItem>
    </asp:DropDownList>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" 
        ErrorMessage="RequiredFieldValidator" ControlToValidate="DropDownList1">*</asp:RequiredFieldValidator>
    </td>

</tr>

<tr>
<th>
    <asp:Label ID="Labe11" runat="server" Text="Secret Answer"></asp:Label></th>
<td align="left">
    <asp:TextBox ID="TextBox10" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" 
        ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox10">*</asp:RequiredFieldValidator>
    </td>

</tr>

<tr>
<th></th><th></th>
<td align="left">
    <asp:Button ID="Button1" OnClick="Button1_Click" runat="server" Text="Submit" />

    </td>

</tr>


</table>




    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:CourierSystemConnectionString %>" 
    InsertCommand="Insert_StaffRegis_Table"
            InsertCommandType="StoredProcedure" 
    SelectCommand="SELECT [StaffID], [FirstName], [LastName], [Password], [RetypePass], [Gender], [Designation], [DOB], [Department], [SecretQues], [SecretAns] FROM [StaffRegis_Table]">
    <InsertParameters>
                <asp:Parameter Name="StaffID" Type="String" />
                <asp:Parameter Name="FirstName" Type="String" />
                <asp:Parameter Name="LastName" Type="String" />
                <asp:Parameter Name="Password" Type="String" />
                <asp:Parameter Name="RetypePass" Type="String" />
                 <asp:Parameter Name="SecretQues" Type="String" />
                <asp:Parameter Name="SecretAns" Type="String" />
                 <asp:Parameter Name="Gender" Type="String" />
                  <asp:Parameter Name="DOB" Type="String" />
                   <asp:Parameter Name="Department" Type="String" />
                    <asp:Parameter Name="Designation" Type="String" />



            </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.