protected void LinkButton1_Click(object sender, EventArgs e) { Panel1.Visible = true; int flag = 1; DatabaseHandler obj = new DatabaseHandler(); EncryptDecrypt obj1 = new EncryptDecrypt(); String sellerId = obj1.Decrypt(HttpUtility.UrlDecode(Request.QueryString["sellerId"].ToString())); DataSet ds = obj.GetSellerCars(sellerId); if (ds.Tables[0].Rows.Count == 0) { Label7.Text = "This seller has no car in stock"; LinkButton1.Visible = false; } else { int count1 = ds.Tables[0].Rows.Count; TableRow tr = new TableRow(); for (int i = 0; i < count1; i++) { LinkButton1.Visible = false; TableCell tc = new TableCell(); Image img = new Image(); img.ImageUrl = "~\\Car\\Front\\" + Path.GetFileName(ds.Tables[0].Rows[i]["CAR_FRONT_IMAGE"].ToString()); img.Width = 150; img.Height = 150; tc.Controls.Add(img); 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(); DataSet ds1 = obj.GetCarSeller(carId); carId = HttpUtility.UrlEncode(obj1.Encrypt(carId)); sellerId = HttpUtility.UrlEncode(obj1.Encrypt(sellerId)); lbutton1.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.Controls.Add(tc); tr = new TableRow(); } } Table1.Rows.Add(tr); Table1.CellSpacing = 30; } }