无法在选定列表中存储列表 [英] unable to store list in selected list

查看:70
本文介绍了无法在选定列表中存储列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SelectList objselectlist = new SelectList(TestList,Id,CountryName);





这里testlist是一个列表(它有存储在其中的值值。)我想在objselectlist中获取该值,但它显示为null

SelectList objselectlist = new SelectList(TestList, "Id", "CountryName");


here testlist is a list(it has sme value storing inside it ).i want to get that values in objselectlist but its showing null

推荐答案

尝试这样:

Try like this:
public SelectList GetAllprofsssinList()
{
   var PList = new List<professional();>

   ds = dropdown.GetDropDownList();
   List<SelectListItem> lstProfessional = new List<SelectListItem>();

   for (int record = 0; record <= ds.Tables[1].Rows.Count - 1; record++)
   {
      dynamic row = ds.Tables[1].Rows[record];

      // adding records to list of professional
      lstProfessional.Add(
          new SelectListItem  
          {  
             Text = Convert.ToString(row["ID"]), 
	         Value = Convert.ToString(row[DescriptionName]
          });
   }

  // generate SelectList object
  SelectList testList = new SelectList(lstProfessional);

  // returning list
  return testList;
}


这篇关于无法在选定列表中存储列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆