如何检索一列表的所有行并在页面上显示 [英] How to Retrieve all rows of one column of table and display on page

查看:75
本文介绍了如何检索一列表的所有行并在页面上显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有



我想显示表格中一列所有行的列表并将其显示在选框上请告诉我如何执行此操作。我正在尝试执行以下代码,但它只显示最后一行



Dear All

I want to display a list of all the rows of one column of a table and display it on the marquee please tell me how to do this. I am trying to do the following code but it is only displaying a last row

TestDbEntities TE = new TestDbEntities();
      protected void Page_Load(object sender, EventArgs e)
      {
          string[] ids = (from customer in TE.tblUploadeds
                    select customer.Thefile).ToArray();

          foreach(var fn in ids)
          {
              TitleLink.Text = fn.ToString() + "<br />";
          }
      }

推荐答案

它只显示最后一行,因为你覆盖了所有其他数据每次循环控制。



附加新数据:

It's only displaying the last row, because you overwrite all the other data in the control each time round the loop.

Either append the new data:
TitleLink.Text += fn.ToString() + "<br />";

或者使用一个控件来显示多行,例如GridView。

Or use a control which is intended to show multiple rows such as a GridView.


这篇关于如何检索一列表的所有行并在页面上显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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