我想创建多个网格视图。我想从代码后面(.cs)文件中添加它们。这是我几乎可以工作的代码。但是任何人都可以找到这有什么问题吗?
示例.aspx:
<body>
<form id="form1" runat="server">
<%CreateGridView();%>
</form>
</body>
示例.aspx.cs:
using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected GridView CreateGridView()
{
GridView gv = new GridView();
gv.ID = "_gridview1";
Queue q = new Queue();
for (int i = 0; i < 20; i++)
q.Enqueue(i);
gv.DataSource = q;
gv.DataBind();
gv.Visible = true;
return gv;
}
}