Menu Table ------------------------------- MenuId MenuName ------------------------------- 11 Shirts
Product Table --------------------------------------------- ProductId ProductName MenuId ProductImage --------------------------------------------- 1 Levisshirts 11 image 2 white shirt 11 image2
{ con.Open(); if (!IsPostBack) ddlbind(); } private void BindGridData() { SqlCommand command = new SqlCommand("SELECT * from rsa_ProductItemTable where MenuId=" + Dropsearch.SelectedItem.Value, con); SqlDataAdapter daimages = new SqlDataAdapter(command); DataSet ds = new DataSet(); daimages.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); GridView1.Attributes.Add("bordercolor", "black"); } public void ddlbind() { SqlCommand command = new SqlCommand("SELECT * from rsa_mastermenu", con); SqlDataAdapter daimages = new SqlDataAdapter(command); DataTable dt = new DataTable(); daimages.Fill(dt); Dropsearch.DataSource = dt; Dropsearch.DataTextField = "MenuName"; Dropsearch.DataValueField = "MenuId"; Dropsearch.DataBind(); Dropsearch.Items.Insert(0, new ListItem("Select", "0")); } protected void Dropsearch_SelectedIndexChanged(object sender, EventArgs e) { int imgid = int.Parse(Dropsearch.SelectedItem.Value); BindGridData(); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Image img = (Image)e.Row.FindControl("Image1"); img.ImageUrl = "GridviewImage.ashx?ImID=" + Dropsearch.SelectedItem.Value; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)