A
Alex. O. Koranteng
I am attempting to load gridview using a class module. The module is called
by the OnClick_Event of button. All my controls are within the script manager
and Update panels. I have clientside code to show the status of completion of
load, but I am getting Error load message. Please find below my
class module; I could send the rest of the sample code. Any suggestions
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Configuration;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Web.Compilation;
/// <summary>
/// Summary description for Class1
/// </summary>
public class GetEmployeesDB
{
private static readonly string _conString;
public static SqlDataReader GetEmployees(string sortExpression, int
startRowIndex, int maximumRows)
{
// Initialize connection
SqlConnection con = new SqlConnection(_conString);
SqlCommand cmd = new SqlCommand("dbo.products_sel", con);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
// Initialize command
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
con.Open();
adapter.Fill(ds, "Employees");
// Create parameters
cmd.Parameters.AddWithValue("@SortExpression", sortExpression);
cmd.Parameters.AddWithValue("@StartRowIndex", startRowIndex);
cmd.Parameters.AddWithValue("@MaximumRows", maximumRows);
// Execute command
//con.Open();
return cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
static GetEmployeesDB()
{
_conString =
WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
}
}
by the OnClick_Event of button. All my controls are within the script manager
and Update panels. I have clientside code to show the status of completion of
load, but I am getting Error load message. Please find below my
class module; I could send the rest of the sample code. Any suggestions
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Configuration;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Web.Compilation;
/// <summary>
/// Summary description for Class1
/// </summary>
public class GetEmployeesDB
{
private static readonly string _conString;
public static SqlDataReader GetEmployees(string sortExpression, int
startRowIndex, int maximumRows)
{
// Initialize connection
SqlConnection con = new SqlConnection(_conString);
SqlCommand cmd = new SqlCommand("dbo.products_sel", con);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
// Initialize command
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
con.Open();
adapter.Fill(ds, "Employees");
// Create parameters
cmd.Parameters.AddWithValue("@SortExpression", sortExpression);
cmd.Parameters.AddWithValue("@StartRowIndex", startRowIndex);
cmd.Parameters.AddWithValue("@MaximumRows", maximumRows);
// Execute command
//con.Open();
return cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
static GetEmployeesDB()
{
_conString =
WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
}
}