Label控件是否可以在foreach语句里显示多个值?望各位高手给予指点!

解决方案 »

  1.   

    比如说根据父表反复显示子表的信息!
    foreach(DataRow drParent in ds.Tables["Categories"].Rows)
    {
    Label1.Text="<h3>" + drParent["CategoryName"] + "</h3>";
    foreach(DataRow drChild in drParent.GetChildRows("Categories_Products"))
    {
    Label1.Text="<li>" + drChild["ProductName"];
    } }
    这样可以在LABEL控件上显示多个值吗?
      

  2.   

    重新规范一下格式!
    foreach(DataRow drParent in ds.Tables["Categories"].Rows)
    {
      Label1.Text="<h3>" + drParent["CategoryName"] + "</h3>";
      foreach(DataRow drChild in drParent.GetChildRows("Categories_Products"))
      {
    Label1.Text="<li>" + drChild["ProductName"];
      }}
      

  3.   

    label1.text = label1.text + drchild