Reputation: 13955
Class File:
public class ServiceAccess
{
public DataTable GetAllShortCodes()
{
DataTable ShortCodeTable = new DataTable();
// logic to add data to Datatable
return ShortCodeTable;
}
}
Code Behind:
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = ServiceAccess.GetAllShortCodes();
}
Been doing VB for a long time, but new to C#. What am I doing wrong?
Upvotes: 1
Views: 1070
Reputation: 19863
You are calling GetAllShortCodes
like a static method
you need to change it to this
var service = new ServiceAccess();
DataTable dt = service.GetAllShortCodes();
or changing the method to a static method as
public static DataTable GetAllShortCodes()
{
DataTable ShortCodeTable = new DataTable();
// logic to add data to Datatable
return ShortCodeTable;
}
Upvotes: 4