Use an adapter to get the data and use it to fill a DataTable then you can read the DataTable row by row and copy into an object that you can use outside of your data accessing code.
Sample to follow momentarily.....
EDIT: Sample added...
public IList<your object> PopulateYourObject()
{
DataSet ds = new DataSet();
SqlConnection con = new SqlConnection(your connection string);
SqlCommand cmd = con.CreateCommand();
cmd.CommandText = command;
if (parameters != null)
{
// add any parameters here
}
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adp = null;
con.Open();
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(ds);
DataTable dt = ds.Tables[0]; // Now you have a DataTable
return PopulateYourObjectListFromData(dt);
}
To Add it to the aspx I would loop throught the rows in the dt
private IList<your object> PopulateYourObjectListFromData(DataTable dt)
{
IList<your object> newsReachArticleList = new List<your object>();
try
{
foreach (DataRow row in dt.Rows)
{
<your object> dto = new <your object>();
<your object>.PropertyToFill = Convert.ToString(row["column name"]);
}
}
}
Then you can apply the IList to the Datasource of the DataGrid in your aspx.
public void LoadData()
{
YourDataGrid.Datasource = PopulateYourObject();
YourDataGrid.DataBind();
}