标题:DATAGRID错误
取消只看楼主
想你的天空
Rank: 2
等 级:新手上路
威 望:5
帖 子:610
专家分:0
注 册:2004-12-30
 问题点数:0 回复次数:0 
DATAGRID错误

public partial class datasetDataGrid : System.Web.UI.Page
{

protected System.Web.UI.WebControls.DataGrid dgrdTest;

protected void Page_Load(object sender, EventArgs e)
{
datagrid_load(sender, e);
}

protected void datagrid_load(object sender, EventArgs e)
{
string strConn = "server=localhost;uid=sa;password=987654321;database=testDB";
SqlConnection conn = new SqlConnection(strConn);
string strSql = "select * from test";
SqlCommand myCommand = new SqlCommand(strSql, conn);
conn.Open();

SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = myCommand;

DataSet myDs = new DataSet();
adapter.Fill(myDs, "Test");
conn.Close();

dgrdTest.DataSource = myDs.Tables[0].DefaultView;
dgrdTest.DataBind();
}

}
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。

搜索更多相关主题的帖子: DATAGRID 
2007-03-26 16:38



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-126950-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.598016 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved