protected void btn_Search_Click(object sender, EventArgs e) { int tempProdCatID = 0; int tempProModID = 0; //// to get product id from product name if (txt_Category.Text != "") { EntityManager<ProductCategory> pcat = new EntityManager<ProductCategory>(); ProductCategory procat = new ProductCategory(); procat.Name = txt_Category.Text.ToString(); List<ProductCategory> prodcatID = pcat.Search(procat); tempProdCatID = prodcatID[0].ProductCategoryID; } //// to get model id from model name if (txt_ModelName.Text != "") { EntityManager<ProductModel> pmod = new EntityManager<ProductModel>(); ProductModel promod = new ProductModel(); promod.Name = txt_ModelName.Text.ToString(); List<ProductModel> prodmodID = pmod.Search(promod); tempProModID = prodmodID[0].ProductModelID; } // assigning the search results EntityManager<Product> mgrProduct = new EntityManager<Product>(); Product product = new Product(); // product.ProductModelID = tempProModID; //product.ProductCategoryID = tempProdCatID; // if(txt_ProductName.Text != null) //product.Name = txt_ProductName.Text.ToString(); if (txt_ModelName.Text != "") product.ProductModelID = tempProModID;// 127; if (txt_Category.Text != "") product.ProductCategoryID = tempProdCatID; if (txt_ProductName.Text != "") product.Name = txt_ProductName.Text.ToString();// "Rear Derailleur"; List<Product> productlist = mgrProduct.Search(product); //gv_Product.DataSource = productlist; //gv_Product.DataBind(); DataList1.DataSource = product; DataList1.DataBind(); }