在搜索功能C#中获取用户的特定ID

时间:2018-09-03 14:40:00

标签: c# asp.net

foreach (uspSearchPatient pat in search)
{
    HyperLink ViewProfile = new HyperLink();
    TableCell patient = new TableCell();
    TableCell profile = new TableCell();
    TableRow trPatient = new TableRow();

    ViewProfile.Text = "View Profile";
    ViewProfile.ID = pat.PatientID;
    Session["PatientID"] = pat.PatientID;
    ViewProfile.NavigateUrl = "ViewProfileByDoctor.aspx";
    profile.Controls.Add(ViewProfile);
    patient.Text = pat.Patient +"("+ pat.PatientID +")";
    trPatient.Cells.Add(patient);
    trPatient.Cells.Add(profile);

    tbSearchResults.Rows.Add(trPatient);             
}

我已经尝试过了。但是它仅返回最后的患者ID。我想获得第一个患者ID

1 个答案:

答案 0 :(得分:0)

尚不清楚您要获取什么,但是基于您在循环中设置Session["PatientID"]的事实,这将导致该会话变量被设置为最后一个PatientID,因为先前的设置值是覆盖。

相关问题