下面是代码..
namespace ConfigurationSystem.DataAccess
{
    public class DataAccessLayer
    {
        public DataSet GetRoleCreationDetails(int? Roles_Id, string Code, string Name, string IsActive)
        {
            try
            {
                string con = @"Data Source=PAVANKUMAR-PC\PAVAN;Initial Catalog=ConfigurationSystem;Integrated Security=True";
                SqlConnection connection = new SqlConnection(con);
                SqlCommand command = new SqlCommand();
                command.Connection = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "SP_GetRoleCreationDetails";
                command.Parameters.AddWithValue("@UserRole_Id", Roles_Id);
                command.Parameters.AddWithValue("@RoleId", Code);
                command.Parameters.AddWithValue("@UserId", Name);
                command.Parameters.AddWithValue("@IsActive", IsActive);
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataSet dataset = new DataSet();
                adapter.Fill(dataset);
                //status = Convert.ToString(command.Parameters["@OuptputParam"].Value);
                return dataset;
            }
            catch (Exception exception)
            {
                throw new ArgumentException(exception.Message);
            }
        }
    }
}发布于 2012-09-26 01:10:43
将数据集传递给UI并执行以下操作:
myGrid.DataSource = GetReturnedDS();
myGrid.DataBind();换句话说,在UI中:
Dataset ds = MyBLL.GetData();
myGrid.DataSource = ds;
myGrid.DataBind();在BLL中:
public static DataSet GetData()
 {
  return  DLL.GetData();
 }在DLL中:
public static DataSet GetData()
 {
  //your code here
  return yourDataSet;
 }发布于 2012-09-26 01:12:34
您需要先创建class DataAccessLayer的object。可以在表单顶部使用,也可以在类名前加上命名空间,如下所示。您需要为您的类和命名空间使用有意义的全名。
grid1.DataSource = new ConfigurationSystem.DataAccess.DataAccessLayer().GetRoleCreationDetails("1", "code", "name", "true");
grid1.DataBind();发布于 2012-09-26 01:12:40
在您的aspx.cs中执行此操作
myGrid.DataSource = new DataAccessLayer().DataGetRoleCreationDetails(parameters here..)
myGrid.DataBind();https://stackoverflow.com/questions/12587829
复制相似问题