C# 新建内存表并绑定到GridView

DataTable dt1 = new DataTable();
            dt1.Columns.Add(“学生投票的总得分”);
            dt1.Columns.Add(“学生数”);
            dt1.Columns.Add(“教师投票的总得分”);
            dt1.Columns.Add(“教师数”);
            dt1.Columns.Add(“领导投票的总得分”);
            dt1.Columns.Add(“领导数”);
            DataRow dr1 = dt1.NewRow();
            dr1[0]=”60″;
            dr1[1] = “30”;
            dr1[2] = “40”;
            dr1[3] = “20”;
            dr1[4] = “20”;
            dr1[5] = “10”;
            dt1.Rows.Add(dr1);
            GridView1.DataSource = dt1;
            GridView1.DataBind();

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注