protected void LinkButton2_Click(object sender, EventArgs e) { DatabaseHandler obj=new DatabaseHandler(); DataSet ds = obj.GetAuctionBids(Session["auctionId"].ToString()); long winnerBid = 0; String winnerUsername = null; foreach (DataRow dr in ds.Tables[0].Rows) { long bid = Convert.ToInt64(dr["CUSTOMER_BID_AMOUNT"].ToString()); if (winnerBid < bid) { winnerBid = bid; winnerUsername = dr["CUSTOMER_USERNAME"].ToString(); } } obj.InsertAuctionWinner(Session["auctionId"].ToString(), winnerUsername); Response.Redirect("AuctionResult.aspx?auctionId=" + Session["auctionId"].ToString()); }