hello,
i have this data table method whcih returns many rows in sql reader
in MVC action result index i want to bind it with view like this snippet
but this snipet using dataset i want to use data table please advice
public DataTable SelectAllCategories()
{
using (SqlConnection con = new SqlConnection(constring))
{
using (SqlCommand cmd = new SqlCommand("sp_categories", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Action", "SelectAll");
DataTable dt = new DataTable();
con.Open();
dt.Load(cmd.ExecuteReader());
con.Close();
return dt;
}
}
}