问题描述
我有logintable包含id,用户名,密码
&
另一个表userdetailtable它包含id和更多列。
如果用户没有在userdetailtable(第一次登录用户)或特定id中填写详细信息,我想去userdetailedit.aspx页面,不存在于userdetailtable中的记录。
或
如果用户详细信息出现在userdetailtable(已经填充的用户)中,我想去用户home.aspx页面
---现在如何在asp.net网页上使用if条件
我是什么尝试过:
i尝试了很多东西
string s =从登录表中选择id where exists(从userdetailtable中选择id,其中id = logintable.id)
if(Session([id]。ToString()== s.ToString( ))
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())
推荐答案
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;
}
}
这篇关于如何根据条件重定向页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!