protected void Page_Load(object sender, EventArgs e)
{ if (!IsPostBack)
{
bind();
}
}
private void bind( )
{ /////把记录总数赋值给分页控件
string AcceptPeople = "admin";// Session["AccountNum"].ToString();
SqlParameter myParam = new SqlParameter();
myParam.Value = AcceptPeople;
myParam.ParameterName = "@AcceptPeople";
myParam.SqlDbType = SqlDbType.VarChar;
string sql = "usp_TaskAllocation_SelectByAccepPeople";
DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.conStr, CommandType.StoredProcedure, sql, myParam);//SqlHelper.ExecuteDataset(SqlHelper.conStr, CommandType.Text,sql, null);
AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;
int pageSize = AspNetPager1.PageSize = 8;
int pageIndex = AspNetPager1.CurrentPageIndex - 1;
////绑定当前页的数据到Repeater控件
DataSet dd = GVBind(sql, pageIndex, pageSize,AcceptPeople);
this.rptCustomerDemand.DataSource = dd.Tables[0];
this.rptCustomerDemand.DataBind();
}
//PageChanged事件处理
protected void AspNetPager1_PageChanging1(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{ AspNetPager1.CurrentPageIndex = e.NewPageIndex; bind(); } //返回当前页dataset
public static DataSet GVBind(string sqlstring, int page_index, int page_size,string AcceptPeople)
{
SqlParameter myParam = new SqlParameter();
myParam.Value = AcceptPeople;
myParam.ParameterName = "@AcceptPeople";
myParam.SqlDbType = SqlDbType.VarChar;
int firstPage = page_index * page_size;
SqlConnection conn = new SqlConnection(SqlHelper.conStr);
DataSet ds = new DataSet();
SqlDataAdapter myConAdp = new SqlDataAdapter(sqlstring,conn);
myConAdp.Fill(ds, firstPage, page_size, "article");
conn.Close();
return ds;
}提示错误在 myConAdp.Fill(ds, firstPage, page_size, "article");。说没有给存储过程参数?
{ if (!IsPostBack)
{
bind();
}
}
private void bind( )
{ /////把记录总数赋值给分页控件
string AcceptPeople = "admin";// Session["AccountNum"].ToString();
SqlParameter myParam = new SqlParameter();
myParam.Value = AcceptPeople;
myParam.ParameterName = "@AcceptPeople";
myParam.SqlDbType = SqlDbType.VarChar;
string sql = "usp_TaskAllocation_SelectByAccepPeople";
DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.conStr, CommandType.StoredProcedure, sql, myParam);//SqlHelper.ExecuteDataset(SqlHelper.conStr, CommandType.Text,sql, null);
AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;
int pageSize = AspNetPager1.PageSize = 8;
int pageIndex = AspNetPager1.CurrentPageIndex - 1;
////绑定当前页的数据到Repeater控件
DataSet dd = GVBind(sql, pageIndex, pageSize,AcceptPeople);
this.rptCustomerDemand.DataSource = dd.Tables[0];
this.rptCustomerDemand.DataBind();
}
//PageChanged事件处理
protected void AspNetPager1_PageChanging1(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{ AspNetPager1.CurrentPageIndex = e.NewPageIndex; bind(); } //返回当前页dataset
public static DataSet GVBind(string sqlstring, int page_index, int page_size,string AcceptPeople)
{
SqlParameter myParam = new SqlParameter();
myParam.Value = AcceptPeople;
myParam.ParameterName = "@AcceptPeople";
myParam.SqlDbType = SqlDbType.VarChar;
int firstPage = page_index * page_size;
SqlConnection conn = new SqlConnection(SqlHelper.conStr);
DataSet ds = new DataSet();
SqlDataAdapter myConAdp = new SqlDataAdapter(sqlstring,conn);
myConAdp.Fill(ds, firstPage, page_size, "article");
conn.Close();
return ds;
}提示错误在 myConAdp.Fill(ds, firstPage, page_size, "article");。说没有给存储过程参数?
还要SelectCommand.Parameters.Add(param);
存储过程这里把myParam放进去。有错误也不知道怎么写。
cmd.Parameters.Add(myParam ); 给命令添加参数 。
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand();
da.SelectCommand.Connection = conn;
da.SelectCommand.CommandText = "getdataset";
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.Add("@TableList", SqlDbType.VarChar, 200).Value = "job_id,job_desc,max_lvl";
谢谢了。 弄好了。还有个问题哦。。如果多个参数怎么办?