C
coolcat3000
Unregistered / Unconfirmed
GUEST, unregistred user!
各位大侠,我是个asp.net的初学都,做了个页面,更新后有记录已经更新成功了,但有时刷新显示,有时不显示,查了很多,也加了 if (!IsPostBack),但还是有这个问题,代码如下,
if (!IsPostBack)
{
if (Request.QueryString["id"] != null &
Request.QueryString["type"] == "up")
{
string sql1 = "select * from product where ArticleID=" + Request.QueryString["id"] + "";
DataSet ds1 = function.sqlds(sql1, "tmp1");
string CurrentId = ds1.Tables["tmp1"].Rows[0]["ArticleID"].ToString();
string CurrentPx = ds1.Tables["tmp1"].Rows[0]["addtime"].ToString();
//
string sql2 = "select top 1 * from product where addtime>#" + CurrentPx + "# order by addtime asc";
DataSet ds2 = function.sqlds(sql2, "tmp2");
string UpId = ds2.Tables["tmp2"].Rows[0]["ArticleID"].ToString();
string UpPx = ds2.Tables["tmp2"].Rows[0]["addtime"].ToString();
//
string sqls1 = "UpDate Product set addtime= '" + UpPx + "' where ArticleID= " + CurrentId;
//
string sqls2 = "UpDate Product set addtime= '" + CurrentPx + "' where ArticleID= " + UpId;
function.SqlExe(sqls1);
function.SqlExe(sqls2);
}
if (!IsPostBack)
{
if (Request.QueryString["id"] != null &
Request.QueryString["type"] == "up")
{
string sql1 = "select * from product where ArticleID=" + Request.QueryString["id"] + "";
DataSet ds1 = function.sqlds(sql1, "tmp1");
string CurrentId = ds1.Tables["tmp1"].Rows[0]["ArticleID"].ToString();
string CurrentPx = ds1.Tables["tmp1"].Rows[0]["addtime"].ToString();
//
string sql2 = "select top 1 * from product where addtime>#" + CurrentPx + "# order by addtime asc";
DataSet ds2 = function.sqlds(sql2, "tmp2");
string UpId = ds2.Tables["tmp2"].Rows[0]["ArticleID"].ToString();
string UpPx = ds2.Tables["tmp2"].Rows[0]["addtime"].ToString();
//
string sqls1 = "UpDate Product set addtime= '" + UpPx + "' where ArticleID= " + CurrentId;
//
string sqls2 = "UpDate Product set addtime= '" + CurrentPx + "' where ArticleID= " + UpId;
function.SqlExe(sqls1);
function.SqlExe(sqls2);
}