protected void Page_Load(object sender, EventArgs e)
 {
     if (!checkCookie())
         Response.Redirect("Login.aspx");
     int flag = 0;
     DataSet ds = new DataSet();
     DatabaseHandler obj = new DatabaseHandler();
     ds = obj.GetAllCars();
     if (ds == null)
         Label1.Text = "No car to display";
     else
     {
         int count = ds.Tables[0].Rows.Count;
         TableRow tr = new TableRow();
         for (int i = 0; i < count; i++)
         {
             TableCell tc = new TableCell();
             ImageButton imgbutton = new ImageButton();
             imgbutton.ImageUrl = "~\\Car\\Front\\" + Path.GetFileName(ds.Tables[0].Rows[i]["CAR_FRONT_IMAGE"].ToString());
             imgbutton.Width = 150;
             imgbutton.Height = 150;
             imgbutton.CssClass = "image-zoom";
             tc.Controls.Add(imgbutton);
             LinkButton lbutton1 = new LinkButton();
             String brand = ds.Tables[0].Rows[i]["CAR_BRAND"].ToString();
             String model = ds.Tables[0].Rows[i]["CAR_MODEL_NAME"].ToString();
             lbutton1.Text = brand + " " + model;
             tc.Controls.Add(lbutton1);
             String carId = ds.Tables[0].Rows[i]["CAR_ID"].ToString();
             String sellerId = ds.Tables[0].Rows[i]["SELLER_ID"].ToString();
             EncryptDecrypt obj1 = new EncryptDecrypt();
             carId = HttpUtility.UrlEncode(obj1.Encrypt(carId));
             sellerId = HttpUtility.UrlEncode(obj1.Encrypt(sellerId));
             lbutton1.PostBackUrl = "CarDetails.aspx?carId=" + carId + "&sellerId=" + sellerId;
             imgbutton.PostBackUrl = "CarDetails.aspx?carId=" + carId + "&sellerId=" + sellerId;
             tc.Attributes.Add("width", "150px");
             tc.Attributes.Add("height", "150px");
             flag++;
             if (flag % 5 != 0)
             {
                 tr.Controls.Add(tc);
             }
             else
             {
                 Table1.Rows.Add(tr);
                 tr = new TableRow();
                 tr.Controls.Add(tc);
             }
         }
         Table1.Rows.Add(tr);
         Table1.CellSpacing = 30;
     }
 }