我在将选定的列表框项导出到数据表时遇到问题,我想将多个选定的植物导出到数据表中,你能帮忙吗?
int numberofplants = 0;
foreach (ListItem li in lbxPlants.Items)
{
if (li.Selected)
{
numberofplants++;
DataTable dtplants = new DataTable();
dtplants.Columns.Add("Plants");
DataRow drplants = dtplants.NewRow();
drplants[0] = li.Value;
dtplants.Rows.Add(drplants);
}
}