ログインページに入力されたユーザー名をキャッチし、対応するプロファイル ID (DB の列) を取得し、それを別のページに表示する必要があります。私の DAL コードは
public DataTable getall()
{
SqlConnection conn1 = Generic.DBConnection.OpenConnection();
DataTable dt=new DataTable();
try
{
string sql = "Select * from Profile_Master";
SqlCommand cmds = new SqlCommand(sql,conn1);
SqlDataAdapter sqlDa = new SqlDataAdapter(cmds);
sqlDa.Fill(dt);
}
catch (Exception ex)
{
throw ex;
}
return dt;
}
私のUI
DataTable dt1 = new DataTable();
ProfileMasterDAL dal = new ProfileMasterDAL();
dt1 = dal.getall();
if (dt1.Rows.Count > 0)
{
Session["sdds"] = dt1.Rows[0]["FirstName"].ToString();
Session["EmailId"] = dt1.Rows[0]["EmailID"].ToString();
Session["pid"] = dt1.Rows[0]["NewidColumn"].ToString();
Response.Redirect("~/Myhome.aspx");
しかし、ユーザー名に対応する値ではなく、DB の最初の値を取得できますか?