首页 新闻 会员 周边 捐助

求高手指点DataGridViewComBox的绑定方法,下面是我的程序,可是有问题

0
悬赏园豆:5 [已关闭问题] 关闭于 2015-12-01 11:28

这个我的效果,但是每个菜单的价格列表变成都一样,数据库中的字段有些是一个价格,有些是多个价格组合起来的(如7,8,9)这是后台的代码                

private void ShowData(List<MFood> modelList)
{
dataFoodList.Rows.Clear();
DataGridViewComboBoxColumn DgvCell = (DataGridViewComboBoxColumn)dataFoodList.Columns["dvPrice"];
foreach (var model in modelList)
{
string[] reg = model.Price.Split(',');


// //DataGridViewComboBoxCell DgvCell = dataFoodList.Rows[dataFoodList.Rows.Count].Cells["dvPrice"] as DataGridViewComboBoxCell;
// DgvCell.Items.AddRange(reg);

dataFoodList.SetDataGridViewColumns(model, -1, "dvIsEnable,dvCreateDatetime,dvUpdateDatetime,dvPrice");
dataFoodList.Rows[dataFoodList.Rows.Count - 1].Cells["dvCreateDatetime"].Value = model.CreateDatetime.Date.ToString("yyyy-MM-dd");
dataFoodList.Rows[dataFoodList.Rows.Count - 1].Cells["dvUpdateDatetime"].Value = model.UpdateDatetime.ToString("yyyy-MM-dd");
if (reg != null)
{
foreach (var price in reg)
{
//dataFoodList.Rows[dataFoodList.Rows.Count - 1].Cells["dvPrice"].Value = price;
DgvCell.Items.AddRange(price);
}
}
if (model.IsEnable == 1)
dataFoodList.Rows[dataFoodList.Rows.Count - 1].Cells["dvIsEnable"].Value = "有效";
if (model.IsEnable == 0)
dataFoodList.Rows[dataFoodList.Rows.Count - 1].Cells["dvIsEnable"].Value = "无效";
}
}太久没有弄博客了,没多少豆子,请高手给一下经验,不甚感激

问题补充:

这样看应该清楚点

夜空下的男子的主页 夜空下的男子 | 初学一级 | 园豆:31
提问于:2015-11-30 15:44
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册