为啥是0
为什么是0?
我页面上放了一个gridview
点击按钮输出是0为什么
------解决方案--------------------
设置GridView1的属性AutoGenerateColumns="false"
我页面上放了一个gridview
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add("id");
dt.Columns.Add("GrupName");
dt.Columns.Add("safe");
dt.Rows.Add(new object[] { 0, "营业部", "安全" });
dt.Rows.Add(new object[] { 1, "市场部", "安全" });
dt.Rows.Add(new object[] { 2, "研发部","安全" });
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(GridView1.Columns.Count);
}
点击按钮输出是0为什么
------解决方案--------------------
设置GridView1的属性AutoGenerateColumns="false"