0
我想從上面的數據庫查詢填充一個列表框。列表框顯示正確的「PLAYER」結果作爲items.I還要爲所有這些項目分配一個值成員作爲數據庫的「ID」。它可以是這樣嗎?通過列表框中顯示的項目也傳遞值Winforms c#
SqlDataAdapter sdaa = new SqlDataAdapter("SELECT PLAYERS.ID, CAST(PLAYERS.NO AS VARCHAR) + ', ' + PLAYERS.FIRSTNAME AS PLAYER FROM PLAYERS INNER JOIN TEAMS ON PLAYERS.TEAM_ID = TEAMS.ID WHERE (TEAMS.NAME =oly ", con);
DataTable dta = new DataTable();
sdaa.Fill(dta);
for (int i = 0; i < dt.Rows.Count; i++)
{
listBox1.Items.Add(dt.Rows[i]["PLAYER"].ToString());
}
怎麼可以這樣?用代碼? – Apollon
對不起,我不明白你想要什麼。你想手動添加值(使用循環)價值memebers? @Apollon – Tinwor