G
Guest
I have a mothod in a class that return a datareader object as show below and
trying to assign the datareader object to a datagrid but getting this error
message:
CS0120: An object reference is required for the nonstatic field, method, or
property 'intranet.discussion.discussion.GetThreads(int)'
public SqlDataReader GetThreads(int TopicID)
{
SqlConnection objConn = new
SqlConnection(ConfigurationSettings.AppSettings["DNS"]);
objConn.Open();
SqlCommand objCmd = new SqlCommand("sp_getNoticeReply",objConn);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@TopicID",TopicID);
SqlDataReader objReader = objCmd.ExecuteReader();
return objReader;
}
<%@ Import Namespace="intranet.discussion" %>
<aspataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 312px; POSITION:
absolute; TOP: 272px"
runat="server" DataSource="<%# discussion.GetThreads(4) %>">
trying to assign the datareader object to a datagrid but getting this error
message:
CS0120: An object reference is required for the nonstatic field, method, or
property 'intranet.discussion.discussion.GetThreads(int)'
public SqlDataReader GetThreads(int TopicID)
{
SqlConnection objConn = new
SqlConnection(ConfigurationSettings.AppSettings["DNS"]);
objConn.Open();
SqlCommand objCmd = new SqlCommand("sp_getNoticeReply",objConn);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@TopicID",TopicID);
SqlDataReader objReader = objCmd.ExecuteReader();
return objReader;
}
<%@ Import Namespace="intranet.discussion" %>
<aspataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 312px; POSITION:
absolute; TOP: 272px"
runat="server" DataSource="<%# discussion.GetThreads(4) %>">