“datagrid”这个名称在当前上下文中不存在 [英] The name 'datagrid' does not exist in the current context
本文介绍了“datagrid”这个名称在当前上下文中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void ReadRecords()
{
OleDbConnection conn = null ;
OleDbDataReader reader = null ;
尝试
{
conn.Open();
OleDbCommand cmd = new OleDbCommand( 选择* FROM nifty_daily,conn);
reader = cmd.ExecuteReader();
datagrid.DataSource = reader;
datagrid.DataBind();
}
最后
{
如果(reader!= null )reader.Close();
if (conn!= null )conn.Close();
}
}
}
我在datagrid上遇到错误
解决方案
< blockquote>错误说明了一切!
你的gridview / datagrid控件ID似乎与datagrid不同。
检查源页面(.aspx)是否有正确的ID。
希望,这有助于:)
private void ReadRecords()
{
OleDbConnection conn = null;
OleDbDataReader reader = null;
try
{
conn.Open();
OleDbCommand cmd = new OleDbCommand("Select * FROM nifty_daily", conn);
reader = cmd.ExecuteReader();
datagrid.DataSource = reader;
datagrid.DataBind();
}
finally
{
if (reader != null) reader.Close();
if (conn != null) conn.Close();
}
}
}
I got error at datagrid
解决方案
Error says it all !
Your gridview/datagrid control Id seems to different than "datagrid".
Check the source page(.aspx) for the correct Id.
Hope, that helps :)
这篇关于“datagrid”这个名称在当前上下文中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文