Hi micah,
I have created sample code which fullfill your requirement.
HTML
<div>
UserName:
<asp:TextBox ID="txtUserName" Placeholder="Enter a UserName" runat="server" />
<br />
<br />
Password :<asp:TextBox ID="txtPassword" Placeholder="Enter a Password" TextMode="Password"
runat="server" />
<br />
<br />
<asp:Button ID="btnSubmit" Text="Submit" OnClick="Validate" runat="server" />
</div>
C#
protected void Validate(Object sender, EventArgs e)
{
int companyId;
string constr = ConfigurationManager.ConnectionStrings["Constring"].ToString();
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM UserDetails WHERE UserName=@UserName AND Password=@Password", con))
{
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
cmd.Parameters.AddWithValue("@UserName", txtUserName.Text);
cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
sda.Fill(dt);
if (dt.Rows.Count > 0)
{
companyId = int.Parse(dt.Rows[0]["CompanyId"].ToString());
switch (companyId)
{
case 1:
Response.Redirect("A.aspx");
break;
case 2:
Response.Redirect("B.aspx");
break;
case 3:
Response.Redirect("C.aspx");
break;
}
}
}
}
}
SQL
CREATE TABLE UserDetails
(
UserId INT
,UserName VARCHAR(20)
,Password VARCHAR(20)
,CompanyId INT
);
------------------------------
CREATE TABLE CompanyName
(
CompanyId INT
,CompanyName VARCHAR(20)
);
Screenshot