未将对象引用设置到对象的实例。求大神们帮助,

未将对象引用设置到对象的实例。求大神们帮助,,在线等
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
        if (!Page.IsPostBack)
        {
            
            GridView1.DataSource = GetDataset("select * from TestID").Tables[0];
             GridView1.DataBind();
           
        }
    }
    private DataSet GetDataset(string sql)
    {
        string strConn = "data source=PC-20130111CRCF\\SQL;initial catalog=Test;uid=sa;password=sa";
        SqlConnection conn = new SqlConnection(strConn);
        conn.Open();


        SqlDataAdapter da = new SqlDataAdapter(sql, conn);
        DataSet ds = new DataSet();
        da.Fill(ds);

        conn.Close();
        return ds;
    }




    
  
    private void Write()
    {
        DataTable dt = new DataTable();
        string strConn = "data source=PC-20130111CRCF\\SQL;initial catalog=Test;uid=sa;password=sa";
        SqlConnection conn = new SqlConnection(strConn);
        conn.Open();

        dt.Columns.Add("教工号", typeof(string));
        dt.Columns.Add("姓名", typeof(string));
        dt.Columns.Add("周次", typeof(string));
        dt.Columns.Add("星期", typeof(string));
        dt.Columns.Add("节次", typeof(string));
        dt.Columns.Add("课程", typeof(string));
        dt.Columns.Add("考勤情况", typeof(string));

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            DataRow dr = dt.NewRow();
            dr["教工号"] = GridView1.Rows[i].Cells[0].Text;
            dr["姓名"] = GridView1.Rows[i].Cells[1].Text;
            dr["周次"] = ((DropDownList)GridView1.Rows[i].Cells[2].FindControl("GridView1")).SelectedValue;
           dr["星期"] = GridView1.Rows[i].Cells[3].Text;
           dr["节次"] = GridView1.Rows[i].Cells[4].Text;
           dr["课程"] = GridView1.Rows[i].Cells[5].Text;
           dr["考勤情况"] = GridView1.Rows[i].Cells[6].Text;

         
            dt.Rows.Add(dr);
        }
        GridView1.DataSource = dt;
        GridView1.DataBind();
    }

   



    protected void Button1_Click1(object sender, EventArgs e)
    {
        Write();
    }
}

文章评论

未将对象引用设置到对象的实例。求大神们帮助,
程序员应该关注的一些事儿
未将对象引用设置到对象的实例。求大神们帮助,
老程序员的下场
未将对象引用设置到对象的实例。求大神们帮助,
要嫁就嫁程序猿—钱多话少死的早
未将对象引用设置到对象的实例。求大神们帮助,
60个开发者不容错过的免费资源库
未将对象引用设置到对象的实例。求大神们帮助,
程序猿的崛起——Growth Hacker
未将对象引用设置到对象的实例。求大神们帮助,
程序员的一天:一寸光阴一寸金
未将对象引用设置到对象的实例。求大神们帮助,
聊聊HTTPS和SSL/TLS协议
未将对象引用设置到对象的实例。求大神们帮助,
代码女神横空出世
未将对象引用设置到对象的实例。求大神们帮助,
那些争议最大的编程观点
未将对象引用设置到对象的实例。求大神们帮助,
为什么程序员都是夜猫子
未将对象引用设置到对象的实例。求大神们帮助,
程序员和编码员之间的区别
未将对象引用设置到对象的实例。求大神们帮助,
每天工作4小时的程序员
未将对象引用设置到对象的实例。求大神们帮助,
一个程序员的时间管理
未将对象引用设置到对象的实例。求大神们帮助,
Java程序员必看电影
未将对象引用设置到对象的实例。求大神们帮助,
团队中“技术大拿”并非越多越好
未将对象引用设置到对象的实例。求大神们帮助,
老美怎么看待阿里赴美上市
未将对象引用设置到对象的实例。求大神们帮助,
如何成为一名黑客
未将对象引用设置到对象的实例。求大神们帮助,
我是如何打败拖延症的
未将对象引用设置到对象的实例。求大神们帮助,
旅行,写作,编程
未将对象引用设置到对象的实例。求大神们帮助,
程序员的样子
未将对象引用设置到对象的实例。求大神们帮助,
Web开发者需具备的8个好习惯
未将对象引用设置到对象的实例。求大神们帮助,
10个帮程序员减压放松的网站
未将对象引用设置到对象的实例。求大神们帮助,
不懂技术不要对懂技术的人说这很容易实现
未将对象引用设置到对象的实例。求大神们帮助,
十大编程算法助程序员走上高手之路
未将对象引用设置到对象的实例。求大神们帮助,
我的丈夫是个程序员
未将对象引用设置到对象的实例。求大神们帮助,
科技史上最臭名昭著的13大罪犯
未将对象引用设置到对象的实例。求大神们帮助,
为啥Android手机总会越用越慢?
未将对象引用设置到对象的实例。求大神们帮助,
程序员眼里IE浏览器是什么样的
未将对象引用设置到对象的实例。求大神们帮助,
什么才是优秀的用户界面设计
未将对象引用设置到对象的实例。求大神们帮助,
看13位CEO、创始人和高管如何提高工作效率
未将对象引用设置到对象的实例。求大神们帮助,
我跳槽是因为他们的显示器更大
未将对象引用设置到对象的实例。求大神们帮助,
写给自己也写给你 自己到底该何去何从
未将对象引用设置到对象的实例。求大神们帮助,
“懒”出效率是程序员的美德
未将对象引用设置到对象的实例。求大神们帮助,
初级 vs 高级开发者 哪个性价比更高?
未将对象引用设置到对象的实例。求大神们帮助,
程序员周末都喜欢做什么?
未将对象引用设置到对象的实例。求大神们帮助,
做程序猿的老婆应该注意的一些事情
未将对象引用设置到对象的实例。求大神们帮助,
亲爱的项目经理,我恨你
未将对象引用设置到对象的实例。求大神们帮助,
鲜为人知的编程真相
未将对象引用设置到对象的实例。求大神们帮助,
总结2014中国互联网十大段子
未将对象引用设置到对象的实例。求大神们帮助,
程序员必看的十大电影
未将对象引用设置到对象的实例。求大神们帮助,
当下全球最炙手可热的八位少年创业者
未将对象引用设置到对象的实例。求大神们帮助,
如何区分一个程序员是“老手“还是“新手“?
未将对象引用设置到对象的实例。求大神们帮助,
漫画:程序员的工作
未将对象引用设置到对象的实例。求大神们帮助,
Java 与 .NET 的平台发展之争
未将对象引用设置到对象的实例。求大神们帮助,
“肮脏的”IT工作排行榜