Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot add data to database using pop up extender
    primarykey
    data
    text
    <p>I am using AJAX modal popup extender as a sub form. I have a page with text boxes, when a user click a button the data from text boxes should be added to the database and popup appear. The problem is that when the button is clicked, pop up appears but nothing is added to database. If i comment the pop up, everything works fine. Please help. Thanx</p> <pre><code>&lt;asp:Button ID="btnNewSubmt" runat="server" Text="Submit" ValidationGroup = "NewUser" onclick="btnNewSubmt_Click" OnClientClick = "return isPageValid()"/&gt; &lt;asp:Button ID="btnValidPopUp" runat="server" Text="Button" style = "display:none"/&gt; &lt;asp:Panel ID="pnlUserWorkShop" runat="server"&gt; &lt;asp:SqlDataSource ID="sqlWorkSName" runat="server" ConnectionString="&lt;%$ ConnectionStrings:WildLife_EducationConnectionString %&gt;" SelectCommand="SELECT DISTINCT [WorkshopName] FROM [tblWorkshop]"&gt;&lt;/asp:SqlDataSource&gt; &lt;asp:Label runat="server" Text="Please select work shop you would like to register for:"&gt;&lt;/asp:Label&gt; &lt;asp:DropDownList ID="ddlWorkShopChose" runat="server" DataSourceID="sqlWorkSName" AppendDataBoundItems="True" DataTextField="WorkshopName" DataValueField="WorkshopName"&gt; &lt;asp:ListItem&gt;&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;/asp:Panel&gt; &lt;asp:ModalPopupExtender ID="mdlUserWorkShop" runat="server" TargetControlID = "btnValidPopUp" PopupControlID = "pnlUserWorkShop" BehaviorID = "myModalPopup" &gt; &lt;/asp:ModalPopupExtender&gt; </code></pre> <p>Code behind:</p> <pre><code>using (SqlConnection conn = new SqlConnection(@"Data Source=MyDataBase;Initial Catalog=MyDataBase;Integrated Security=True;")) SqlCommand CmdSql = new SqlCommand ("INSERT INTO [tbluser] ([UserLastName], [UserFirstName], [UserMiddleInitial]) VALUES (@UserFirstName,@UserLastName, @UserFirstName, @UserMiddleInitial)", conn); conn.Open(); CmdSql.Parameters.AddWithValue("@UserLastName", txtNewUserLN.Text.ToString()); CmdSql.Parameters.AddWithValue("@UserFirstName", txtNewUserFN.Text.ToString()); CmdSql.Parameters.AddWithValue("@UserMiddleInitial", txtNewUserMI.Text.ToString()); CmdSql.Connection = conn; CmdSql.ExecuteNonQuery(); conn.Close(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload