Click here to Skip to main content
15,878,748 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have "logintable" contains id,username,password
&
another table "userdetailtable" it contains id, and more columns.

I want to go userdetailedit.aspx page if user not filling the details in userdetailtable (first time login user) or particular id,records not present in userdetailtable.

OR

I want to go user home.aspx page if users detail are present in userdetailtable (already filling user)

---Now how to i use if condition in asp.net web page

What I have tried:

i tried many things

string s = "select id from logintable where exists (select id from userdetailtable where id = logintable.id)"

if (Session(["id"].ToString() == s.ToString())
Posted
Updated 12-Feb-18 21:08pm
Comments
ZurdoDev 12-Feb-18 14:27pm    
This is very, very easy to do so where are you stuck? I do not understand.
Laxmidhar tatwa technologies 13-Feb-18 1:58am    
In where condition send session data.
U can use count statement

1 solution

You can code as below for redirect page based on condition:
protected void btn_login_Click(object sender, EventArgs e)
{
	try
	{
		System.Data.SqlClient.SqlDataAdapter sqlDataAdapter = new System.Data.SqlClient.SqlDataAdapter("your query", "connectionstring");	
		DataSet dsResult = new DataSet();
		sqlDataAdapter.Fill(dsResult);

		if (dsResult.Tables[0].Rows.Count > 0)
		{
			redirect to home.aspx
		}
		else
		{
			redirect to userdetailedit.aspx
		}
	}
	catch (Exception ex)
	{
		throw ex;
	}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900