C# 存储要列出的值并将该列表传递给另一个窗体
我有两张桌子:C# 存储要列出的值并将该列表传递给另一个窗体,c#,.net,C#,.net,我有两张桌子: tblUserType带列:colTypeId和colTypeName 及 tblUsers带列:colUserName,coltypeId 当用户希望从数据库中删除类型并且该类型Id正在使用(外键)时,我希望显示确认窗口,其中包含具有该类型Id的用户的信息 比如说 int exist = this.tblUsersTableAdapter1.FillByTypeId(appDataSet.tblUsers, typeId); if (exist >= 1) {
tblUserType
带列:colTypeId
和colTypeName
及
tblUsers
带列:colUserName
,coltypeId
当用户希望从数据库中删除类型并且该类型Id正在使用(外键)时,我希望显示确认窗口,其中包含具有该类型Id的用户的信息
比如说
int exist = this.tblUsersTableAdapter1.FillByTypeId(appDataSet.tblUsers, typeId);
if (exist >= 1)
{
foreach (DataRow dr in appDataSet.tblUsers.Rows)
{
// string userName = dr["colUserName"].ToString();
// show message box once but with all username (stringBuilder.Append)
// or better, create List and pass List to another form
// for displaying List in listbox
}
}
使用
变量名称列表=(来自appDataSet.tblUsers.Rows中的dr)
选择dr[“colUserName”].ToString()).ToList()
要获取姓名列表