C# 在搜索函数c中获取用户的特定ID#
我试过这个。但它只返回最后一个患者ID。我想获取第一个患者ID,但并不完全清楚您想要获取什么,但根据您在循环中设置的C# 在搜索函数c中获取用户的特定ID#,c#,asp.net,C#,Asp.net,我试过这个。但它只返回最后一个患者ID。我想获取第一个患者ID,但并不完全清楚您想要获取什么,但根据您在循环中设置的Session[“PatientID”],这将导致将此Session变量设置为最后一个PatientID,因为之前的设置值被覆盖。Hi。你能编辑你的问题并添加更多关于你想要什么的细节吗。你的标题上写着具体的id,你的问题是关于第一个和最后一个id以及某种返回。在代码中看不到任何返回。您只需重复(可能)搜索结果。 foreach (uspSearchPatient pat in se
Session[“PatientID”]
,这将导致将此Session变量设置为最后一个PatientID,因为之前的设置值被覆盖。Hi。你能编辑你的问题并添加更多关于你想要什么的细节吗。你的标题上写着具体的id,你的问题是关于第一个和最后一个id以及某种返回。在代码中看不到任何返回。您只需重复(可能)搜索结果。
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);
}