ilist的头疼问题!!!
这是我定义的一个方法:
private const string seach_item = "select itemName from ItemTab ";
public IList<Item> getItemName()
{
IList<Item> list = new List<Item>();
using (OracleDataReader odr = OracleHelper.ExecuteReader(OracleHelper.ConnectionStringFrame, CommandType.Text, seach_item, null))
{
while (odr.Read())
{
Item it = new Item();
it.ItemName = odr[0].ToString();
list.Add(it);
}
}
return list;
}
这是调用:
IitemBll items=(IitemBll) new ItemBll();
//ItemBll it = new ItemBll();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
getItemName();
}
}
private void getItemName()
{
IList<Item> list = items.getItemName();
this.txt_item1.Text = list[0].ToString();
this.txt_item2.Text = list[1].ToString();
this.txt_item3.Text = list[2].ToString();
this.txt_item4.Text = list[3].ToString();
this.txt_item5.Text = list[4].ToString(); }
怎么显示不出来呢?我就郁闷了!是不是加红的那一段写错了?