protected void Button2_Click(object sender, EventArgs e) { String brand = TextBox1.Text; String model = TextBox2.Text; if (brand == "" && model == "") Label1.Text = "Please enter at least one parameter"; else { Label1.Text = ""; DatabaseHandler obj = new DatabaseHandler(); DataSet ds = obj.SearchCar(brand, model); if (ds != null) { Panel1.Visible = true; int flag = 1; Table table = new Table(); int count = ds.Tables[0].Rows.Count; for (int i = 0; i < count; i++) { if (flag == 1) { TableRow row1 = new TableRow(); TableCell cell_name = new TableCell(); Label label_name = new Label(); label_name.Text = "Car Name"; label_name.Font.Size = 15; cell_name.Controls.Add(label_name); TableCell cell_price = new TableCell(); Label label_price = new Label(); label_price.Text = "Car Price"; label_price.Font.Size = 15; cell_price.Controls.Add(label_price); TableCell cell_condition = new TableCell(); Label label_condition = new Label(); label_condition.Text = "Car Condition"; label_condition.Font.Size = 15; cell_condition.Controls.Add(label_condition); TableCell cell_image = new TableCell(); Label label_image = new Label(); label_image.Text = "Car Image"; label_image.Font.Size = 15; cell_image.Controls.Add(label_image); row1.Controls.Add(cell_name); row1.Controls.Add(cell_price); row1.Controls.Add(cell_condition); row1.Controls.Add(cell_image); table.Rows.Add(row1); flag = 0; } TableRow row = new TableRow(); row.Attributes.Add("height", "150px"); row.Attributes.Add("width", "150px"); TableCell cell1 = new TableCell(); Label label1 = new Label(); label1.Text = ds.Tables[0].Rows[i]["CAR_BRAND"].ToString() + " " + ds.Tables[0].Rows[i]["CAR_MODEL_NAME"].ToString(); cell1.Controls.Add(label1); row.Cells.Add(cell1); TableCell cell2 = new TableCell(); Label label2 = new Label(); label2.Text = ds.Tables[0].Rows[i]["CAR_PRICE"].ToString(); cell2.Controls.Add(label2); row.Cells.Add(cell2); TableCell cell3 = new TableCell(); Label label3 = new Label(); label3.Text = ds.Tables[0].Rows[i]["CAR_POSSESSION_TYPE"].ToString(); cell3.Controls.Add(label3); row.Cells.Add(cell3); TableCell cell4 = new TableCell(); Image image = new Image(); image.ImageUrl = "~\\Car\\Front\\" + Path.GetFileName(ds.Tables[0].Rows[i]["CAR_FRONT_IMAGE"].ToString()); image.Width = 100; image.Height = 100; cell4.Controls.Add(image); row.Cells.Add(cell4); table.Rows.Add(row); } table.Attributes.Add("border", "1px solid"); Panel1.Controls.Add(table); } else { Label1.Text = "No results"; Panel1.Visible = false; } } }