title: Asp.net button not working
body: <p>When I click the button the information doesn't load into my table.</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmManageUsers.aspx.cs" Inherits="frmManageUsers" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head id="Head1" runat="server"&gt;
      &lt;title&gt;Untitled Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div align="center"&gt;
  
          &lt;asp:ImageButton ID="ImageButton1" runat="server" 
              ImageUrl="~/images/CoolBiz_Productions_logo.JPG" PostBackUrl="~/frmMain.aspx" /&gt;
  
          &lt;br /&gt;
          &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" 
              ConnectionString="&lt;%$ ConnectionStrings:ConnectionString %&gt;" 
              ProviderName="&lt;%$ ConnectionStrings:ConnectionString.ProviderName %&gt;" 
  
  
              SelectCommand="SELECT [UserID], [UserName], [UserPassword], [SecurityLevel] FROM [tblUserLogin]"&gt;
          &lt;/asp:SqlDataSource&gt;
  
      &lt;/div&gt;
          &lt;div align="center"&gt;
          &lt;asp:Label ID="Label1" runat="server" Text="Manage Users"&gt;&lt;/asp:Label&gt;
      &lt;p&gt;
          &lt;asp:Label ID="Label2" runat="server" Text="User Name:"&gt;&lt;/asp:Label&gt;
          &lt;asp:TextBox ID="txtUserName" runat="server"&gt;&lt;/asp:TextBox&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;asp:Label ID="Label3" runat="server" Text="Password:"&gt;&lt;/asp:Label&gt;
          &lt;asp:TextBox ID="txtPassword" runat="server"&gt;&lt;/asp:TextBox&gt;
      &lt;/p&gt;
              &lt;p&gt;
                  &lt;asp:Label ID="Label4" runat="server" Text="Security Level:"&gt;&lt;/asp:Label&gt;
                  &lt;asp:DropDownList ID="drpdwnlstSecurityLevel" runat="server" 
                      onselectedindexchanged="drpdwnlstSecurityLevel_SelectedIndexChanged"&gt;
                      &lt;asp:ListItem&gt;A&lt;/asp:ListItem&gt;
                      &lt;asp:ListItem&gt;U&lt;/asp:ListItem&gt;
                  &lt;/asp:DropDownList&gt;
      &lt;/p&gt;
              &lt;p&gt;
                  &lt;asp:Button ID="btnAddUser" runat="server" Text="Add User" 
                      onclick="btnAddUser_Click1" /&gt;
      &lt;/p&gt;
              &lt;p&gt;
                  &lt;asp:Label ID="lblError" runat="server"&gt;&lt;/asp:Label&gt;
      &lt;/p&gt;
  
          &lt;/div&gt;
      &lt;p&gt;
          &amp;nbsp;&lt;/p&gt;
                  &lt;div align="center"&gt;
      &lt;asp:GridView ID="tblUserLogin" runat="server" AutoGenerateColumns="False" 
          DataSourceID="SqlDataSource1"&gt;
          &lt;Columns&gt;
              &lt;asp:BoundField DataField="UserID" HeaderText="UserID" InsertVisible="False" 
                  SortExpression="UserID"&gt;&lt;/asp:BoundField&gt;
              &lt;asp:BoundField DataField="UserName" HeaderText="UserName" 
                  SortExpression="UserName"&gt;&lt;/asp:BoundField&gt;
              &lt;asp:BoundField DataField="UserPassword" HeaderText="UserPassword" 
                  SortExpression="UserPassword"&gt;&lt;/asp:BoundField&gt;
              &lt;asp:BoundField DataField="SecurityLevel" HeaderText="SecurityLevel" 
                  SortExpression="SecurityLevel"&gt;&lt;/asp:BoundField&gt;
              &lt;asp:CommandField ShowEditButton="True" /&gt;
              &lt;asp:CommandField ShowDeleteButton="True" /&gt;
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
      &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is my code for frmManageUsers</p>
  
  <pre><code>    public partial class frmManageUsers : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
      }
  
      protected void btnAddUser_Click1(object sender, EventArgs e)
      {
                  //string userName, userPassword;
  
  
  
          if (txtUserName.Text == "" || txtUserName.Text == null)
          {
              lblError.Text = ("User Name may not be empty");
              lblError.ForeColor = System.Drawing.Color.Red;
              return;
          }
         // else
  
             // userName = (txtUserName.Text);
  
  
          if (txtPassword.Text == "" || txtPassword.Text == null)
          {
              lblError.Text = ("Password may not be empty");
              lblError.ForeColor = System.Drawing.Color.Red;
              return;
          }
          //else
             // userPassword = (txtPassword.Text);
  
  
  
  
          Session["UserName"] = txtUserName.Text;
          Session["Password"] = txtPassword.Text;
          Session["SecurityLevel"] = drpdwnlstSecurityLevel.SelectedValue;
          Server.Transfer("frmManageUsers.aspx");
  
  
  
          //Server.Transfer("grdUserLogin"); 
  
      }
      protected void drpdwnlstSecurityLevel_SelectedIndexChanged(object sender, EventArgs e)
      {
  
      }
  }
  </code></pre>