62,271
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}
protected void BindData()
{
int totalOrders = (int)SqlHelp.ExecuteScalar(CommandType.StoredProcedure,"P_Table_Count",
new SqlParameter("@tablename","SXWY_B_Stocks"),
new SqlParameter("@where",sSql),
new SqlParameter("@cell","Id"));
AspNetPager1.RecordCount = totalOrders;
repeater.DataSource = SqlHelp.ExecuteReader(CommandType.StoredProcedure, "P_Tabel_List",
new SqlParameter("@startIndex", AspNetPager1.StartRecordIndex),
new SqlParameter("@endIndex", AspNetPager1.StartRecordIndex + AspNetPager1.PageSize - 1),
new SqlParameter("@where", sSql),
new SqlParameter("@topnum", "0"),
new SqlParameter("@tablename", "SXWY_B_Stocks"),
new SqlParameter("@cell", "Id"),
new SqlParameter("@OrderWay", "desc"));
repeater.DataBind();
}
protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
BindData();
}
public static SqlDataReader ExecuteReader(CommandType cmdType, string cmdText, params SqlParameter[] cmdParms)
{
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(ConString);
// we use a try/catch here because if the method throws an exception we want to
// close the connection throw code, because no datareader will exist, hence the
// commandBehaviour.CloseConnection will not work
try
{
PrepareCommand(cmd, conn, null, cmdType, cmdText, cmdParms);
SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
cmd.Parameters.Clear();
return rdr;
}
catch
{
conn.Close();
throw;//跳到这里了
}
}