页面显示数据 返回一个泛型集合 然后将这个泛型集合 foreach 循环显示在页面上 可以代码前置的 或者后置也行 哈哈 麻烦 帮帮忙 我菜菜啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 假设返回泛型集合的方法是GetData():<asp:GridView ID="GridView1" runat="server" ></asp:GridView><script runat="server"> protected void Page_Load(object sender, EventArgs e) { GridView1.DataSource = GetData(); GridView1.DataBind(); }</script> 感谢楼上的,但是我不想用控件我 你教我怎么将返回的泛型集合用一个Table显示出来 List<T> lst=new List<T>();foreach(T t in lst){} GridView1 生成以后就是 table 直接来 User表 name和age两个字段List<User>找出来了现在把它显示在页面上,上一个HTML Table 怎么把 name和age显示出来 而且是很多条 我写的 献丑了 List<Dictionary<string, List<Categories>>> list = CategoriesManage.GetCategories();//获取泛型集合 Dictionary<string, List<Categories>> dic = list[0]; foreach (string s in dic.Keys) { List<Categories> list1 = dic[s]; Table tb = new Table(); for (int i = 0; i <= 1; i++) { if (i == 0) { TableRow tr = new TableRow(); tb.Rows.Add(tr); TableCell td = new TableCell(); tr.Cells.Add(td); td.ToolTip = s; td.Text = s+"<hr>"; if (td.Text.Length > 4) { td.Text = td.Text.Substring(0, 4) + "...<hr>"; ; } td.Text="<B>"+td.Text+"</B>"; } else { int a = 0; TableRow tr1=null; foreach (Categories c1 in list1) { TableCell td1 = new TableCell(); if (a % 3 == 0) { tr1 = new TableRow(); tb.Rows.Add(tr1); tr1.Cells.Add(td1); td1.ToolTip = c1.Name; td1.Text = c1.Name; if (td1.Text.Length > 4) { td1.Text = td1.Text.Substring(0, 4); } } else { tr1.Cells.Add(td1); td1.ToolTip = c1.Name; td1.Text = c1.Name; if (td1.Text.Length > 4) { td1.Text = td1.Text.Substring(0, 4); } } td1.Text = "<a href='BookList.aspx?typeid="+c1.Id+"'>" + td1.Text + "</a>"; a++; } } } this.P1.Controls.Add(tb); if (IsPostBack)//保持单选按钮的状态 { try { string rdo = ViewState["rdo"].ToString(); if (rdo == "Author") { this.Author.Checked = true; } } catch (Exception) { } } foreach (string k in Session.Keys) { if (k == "CurrentUser") { this.PNoLogin.Visible = false; this.pLoginUser.Visible = true; Users u = Session["CurrentUser"] as Users; this.lbLoginName.Text = u.LoginId; this.lbLoginType.Text = u.UserRoleId.Name; } } } 附件大小的判断问题 C#怎么从图文混排的源代码中,提取图片地址。。 关于gridview里面的选择问题 如何在VS.NET2003中使用并调用AJAX 100分求:以编程方式生成水晶报表的办法。 如何利用Calender控件显示会议日程? 送分:各位高手,看看这是什么原因? ASP.NET OA 请教:关于如何调用.DLL中的,接口的函数 利用EPPlus导出Excel,多个worksheet问题 ASP.NET如何实现文件的上传与下载 关于组件GridView
</asp:GridView><script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataSource = GetData();
GridView1.DataBind();
}
</script>
foreach(T t in lst)
{
}
List<User>找出来了现在把它显示在页面上,上一个HTML Table 怎么把 name和age显示出来 而且是很多条
Dictionary<string, List<Categories>> dic = list[0];
foreach (string s in dic.Keys)
{
List<Categories> list1 = dic[s];
Table tb = new Table();
for (int i = 0; i <= 1; i++)
{
if (i == 0)
{
TableRow tr = new TableRow();
tb.Rows.Add(tr);
TableCell td = new TableCell();
tr.Cells.Add(td);
td.ToolTip = s;
td.Text = s+"<hr>";
if (td.Text.Length > 4)
{
td.Text = td.Text.Substring(0, 4) + "...<hr>"; ;
}
td.Text="<B>"+td.Text+"</B>";
}
else
{
int a = 0;
TableRow tr1=null;
foreach (Categories c1 in list1)
{
TableCell td1 = new TableCell();
if (a % 3 == 0)
{
tr1 = new TableRow();
tb.Rows.Add(tr1);
tr1.Cells.Add(td1);
td1.ToolTip = c1.Name;
td1.Text = c1.Name;
if (td1.Text.Length > 4)
{
td1.Text = td1.Text.Substring(0, 4);
}
}
else
{
tr1.Cells.Add(td1);
td1.ToolTip = c1.Name;
td1.Text = c1.Name;
if (td1.Text.Length > 4)
{
td1.Text = td1.Text.Substring(0, 4);
}
}
td1.Text = "<a href='BookList.aspx?typeid="+c1.Id+"'>" + td1.Text + "</a>";
a++;
}
}
}
this.P1.Controls.Add(tb); if (IsPostBack)//保持单选按钮的状态
{
try
{
string rdo = ViewState["rdo"].ToString();
if (rdo == "Author")
{
this.Author.Checked = true;
}
}
catch (Exception)
{
}
} foreach (string k in Session.Keys)
{
if (k == "CurrentUser")
{
this.PNoLogin.Visible = false;
this.pLoginUser.Visible = true;
Users u = Session["CurrentUser"] as Users;
this.lbLoginName.Text = u.LoginId;
this.lbLoginType.Text = u.UserRoleId.Name;
}
}
}