我在更新面板中有一个gridView我在 OnRowDataBound 事件中设置了一些控件属性 在第一次请求事件中触发,但没有任何反应,我的控件显示
protected void GridViewPur1_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
var isWinner = ((Label)e.Row.FindControl("lblIsWinner")).Visible;
var auctionPayTimeRemain = (Label)e.Row.FindControl("LBLauctionPayTimeRemain");
var lblRemaintime = (Label)e.Row.FindControl("LBLRemainTime");
var IDauctionOrFixPrice = (Label)e.Row.FindControl("LBLAorFID");
var PNLitemAddedToCart = (Label)e.Row.FindControl("PNLitemAddedToCart");
var idItem = ((Label)e.Row.FindControl("LBLidIt")).Text;
var startTime = ((Label)e.Row.FindControl("lblstartTime")).Text;
var endDate = ((Label)e.Row.FindControl("lblendDate")).Text;
var PNLReqToSeller = ((Label)e.Row.FindControl("PNLReqToSeller"));
var btnAddToBasket = (Button)e.Row.FindControl("BTNaddToBasket");
var btnDelBid = (ImageButton)e.Row.FindControl("btnDelBid");
var btnReqToSeller = (Button)e.Row.FindControl("btnReqToSeller");
var imgWinner = (System.Web.UI.WebControls.Image)e.Row.FindControl("imgWinner");
var bidDetailIfPayReq = myfunction.getWinPriceIFpayReqFromSLR(IDauctionOrFixPrice.Text, LBLVUID.Value);
string[] remainTimeAndEnd = RemainTime(IDauctionOrFixPrice.Text);
string endmin = (int.Parse(startTime) % 100).ToString();//36
string endhour = ((int.Parse(startTime) / 100) % 100).ToString();//12
lblRemaintime.Text = remainTimeAndEnd[0] + "<br/>" + (remainTimeAndEnd[1] == "end" ? (endDate + "<br/>" + endhour + ":" + endmin) : "");
var isPayReq = !string.IsNullOrEmpty(bidDetailIfPayReq.Item1);
var payReqStartDate = bidDetailIfPayReq.Item2;
var payReqTotalInHours = SqlHelper.ExecuteScalar("SELECT Duration_Hour+(Duration_Day*24) as 'totalInHours' FROM TimingSystem WHERE IDtimingSystem=3") ?? 48;
var payReqEndDate = payReqStartDate.AddHours(int.Parse(payReqTotalInHours.ToString()));
TimeSpan payReqRemainDif = payReqEndDate.Subtract(DateTime.Now);
var payReqPayTimeRemain = !(payReqRemainDif.Days <= 0 && payReqRemainDif.Hours <= 0 && payReqRemainDif.Minutes <= 0 && payReqRemainDif.Seconds <= 0);
var auctionIsPayable = ((isWinner && Convert.ToBoolean(auctionPayTimeRemain.Text)) || (isPayReq && payReqPayTimeRemain)) && remainTimeAndEnd[1] == "end";
HttpCookie cookie = HttpContext.Current.Request.Cookies["basket"];
var wasAddedToBasket = false;
if (cookie != null && cookie[idItem] != null)
wasAddedToBasket = true;
else
wasAddedToBasket = false;
var addToBasketReqVisible = false;
var isReqable = false;
var hasReq = false;
var acceptedText = "";
if (isWinner && !Convert.ToBoolean(auctionPayTimeRemain.Text) && remainTimeAndEnd[1] == "end")
{
var query2 = "select isAccepted,IDbuyerPaymentRequest from BuyerPaymentRequest where IDitem= " + idItem + " and UID= " + LBLVUID.Value;
DataTable dt = SqlHelper.ExecuteDataset(Constants.ConnectionString, CommandType.Text, query2).Tables[0];
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
var isAccepted = dt.Rows[i]["isAccepted"].ToString();
if (string.IsNullOrEmpty(isAccepted))
{
acceptedText = "request sent";
}
if (isAccepted == "False")
{
acceptedText = "<img src='/images/deleteIcon.gif' />";
}
if (isAccepted == "True")
{
acceptedText = "";
addToBasketReqVisible = true;
}
hasReq = true;
}
}
else if (dt.Rows.Count <= 0)
{
isReqable = true;
}
}
else
{
acceptedText = "";
}
var isVisibleDelBidBtn = false;
var showWinnerImage = false;
if (isWinner && remainTimeAndEnd[1] == "end")
{
showWinnerImage = true;
//mydatarow["addToBasket"] = "<a href='" + myfunction.itemAddressReturn(IDitem, itemName) + "' target='_top' style='font-size: 10pt; font-weight:bold;'>buy</a>";
}
else if (remainTimeAndEnd[1] == "end")
{
isVisibleDelBidBtn = true;
}
btnAddToBasket.Visible = auctionIsPayable && !wasAddedToBasket || (addToBasketReqVisible && !wasAddedToBasket);
PNLitemAddedToCart.Visible = (auctionIsPayable && wasAddedToBasket) || (isReqable && wasAddedToBasket);
btnReqToSeller.Visible = isReqable;
PNLReqToSeller.Visible = hasReq;
PNLReqToSeller.Text = acceptedText;
btnDelBid.Visible = isVisibleDelBidBtn;
imgWinner.Visible = showWinnerImage;
UpdatePanelPur1.Update();
}
}