怎么在dataList控件里的Label控件赋值?
怎么在dataList控件里的Label控件赋值?publicvoidBindNewOrder(){IList<Order>list=orderManager.GetNe...
怎么在dataList控件里的Label控件赋值?
public void BindNewOrder()
{
IList<Order> list = orderManager.GetNewOrderTop10();
for (int i = 0; i < list.Count; i++)
{
Label newOrder = this.dlNewOrder.Items[i].FindControl("lblNewOrder") as Label;
switch (i)
{
case 0:
newOrder.Text = 1.ToString();
break;
case 1:
newOrder.Text = 2.ToString();
break;
}
}
this.dlNewOrder.DataSource = list;
this.dlNewOrder.DataBind();
}
但是:Label newOrder = this.dlNewOrder.Items[i].FindControl("lblNewOrder") as Label;找不到Label控件,请问该怎么来找这里Label控件? 展开
public void BindNewOrder()
{
IList<Order> list = orderManager.GetNewOrderTop10();
for (int i = 0; i < list.Count; i++)
{
Label newOrder = this.dlNewOrder.Items[i].FindControl("lblNewOrder") as Label;
switch (i)
{
case 0:
newOrder.Text = 1.ToString();
break;
case 1:
newOrder.Text = 2.ToString();
break;
}
}
this.dlNewOrder.DataSource = list;
this.dlNewOrder.DataBind();
}
但是:Label newOrder = this.dlNewOrder.Items[i].FindControl("lblNewOrder") as Label;找不到Label控件,请问该怎么来找这里Label控件? 展开
1个回答
展开全部
public void BindNewOrder()
{
IList<Order> list = orderManager.GetNewOrderTop10();
this.dlNewOrder.DataSource = list;
this.dlNewOrder.DataBind();//先绑定数据,不然你循环查找什么啊?
for (int i = 0; i < list.Count; i++)
{
Label newOrder = this.dlNewOrder.Items[i].FindControl("lblNewOrder") as Label;
switch (i)
{
case 0:
newOrder.Text = 1.ToString();
break;
case 1:
newOrder.Text = 2.ToString();
break;
}
}
}
{
IList<Order> list = orderManager.GetNewOrderTop10();
this.dlNewOrder.DataSource = list;
this.dlNewOrder.DataBind();//先绑定数据,不然你循环查找什么啊?
for (int i = 0; i < list.Count; i++)
{
Label newOrder = this.dlNewOrder.Items[i].FindControl("lblNewOrder") as Label;
switch (i)
{
case 0:
newOrder.Text = 1.ToString();
break;
case 1:
newOrder.Text = 2.ToString();
break;
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询