this.LabTitle1.Text=list[0].ImageProductTitle.ToString();
            this.LabTitle2.Text = list[1].ImageProductTitle.ToString();
            this.LabTitle3.Text = list[2].ImageProductTitle.ToString();
            this.LabTitle4.Text = list[3].ImageProductTitle.ToString();
            this.LabTitle5.Text = list[4].ImageProductTitle.ToString();
            this.LabTitle6.Text = list[5].ImageProductTitle.ToString();
            this.LabTitle7.Text = list[6].ImageProductTitle.ToString();
            this.LabTitle8.Text = list[7].ImageProductTitle.ToString();
            this.LabTitle9.Text = list[8].ImageProductTitle.ToString();
            this.LabTitle10.Text = list[9].ImageProductTitle.ToString();
            this.LabTitle11.Text = list[10].ImageProductTitle.ToString();
            this.LabTitle12.Text = list[11].ImageProductTitle.ToString();
            this.LabTitle13.Text = list[12].ImageProductTitle.ToString();
            this.LabTitle14.Text = list[13].ImageProductTitle.ToString();
            this.LabTitle15.Text = list[14].ImageProductTitle.ToString();
如果list没有那么多条数据怎么办?
求一个简单解决的办法。。

解决方案 »

  1.   

     this.LabTitle15.Text = list[14].ImageProductTitle is DBNull? string.Empty,list[14].ImageProductTitle is DBNull.toString() 
      

  2.   

    上面写错了  this.LabTitle15.Text = list[14].ImageProductTitle is DBNull? string.Empty,list[14].ImageProductTitle.toString()
      

  3.   

    用一个循环做
    for(int i = 1;i<16;i++)
    {
    ( Page.FindControl("LabTitle" +i) as Lable).Text = list[i-1].ImageProductTitle.ToString();}
      

  4.   

    string.Empty,list  逗号?
    is DBNull.toString() 是什么意思?
    this.LabTitle2.Text = list[1].ImageProductTitle is DBNull? string.Empty:list[1].ImageProductTitle.ToString(); 
    您说的是这个意思吗
      

  5.   

    if (list.lenght>0) this.LabTitle11.Text = list[0].ImageProductTitle.ToString();...
    ..
    .
    .
    if (list.lenght>14) this.LabTitle15.Text = list[14].ImageProductTitle.ToString();
      

  6.   

     list[14].ImageProductTitle is DBNull
    这一句提示“给定表达式始终不是提供的(System.DBNull)型”