Using product image to direct to the product detail

bucks

New Member
I am trying to use the image control that i have created earlier to direct the image to product details page when the image is clicked: \[code\]ProductDetail.aspx?ProductId={0} )\[/code\]The below code simply is the way I display the image and bind it into my image control. This is my aspx.cs:\[code\]protected string GetProductImgUrl(int productId) { var sqlText = "SELECT pProductImage FROM Products WHERE pProductId = " + productId.ToString(); using (var mDB = new OleDbConnection(ConfigurationManager.ConnectionStrings["AccessConnection"].ConnectionString)) { mDB.Open(); var cmd = new OleDbCommand(sqlText, mDB); using (var rdr = cmd.ExecuteReader()) { if (rdr.Read()) { return ResolveUrl((rdr["pProductImage"]).ToString()); } } } return ResolveUrl("~/images/NotAvailable.png"); // Not available image }\[/code\]This is my mark-up :\[code\] <div class="imagesfloat" > <img width="100" height="100" src='http://stackoverflow.com/questions/14066007/<%= GetProductImgUrl(3) %>' alt="" /> </div>\[/code\]The logic is the same in when I use gridview control where I get URl from data field \[code\]ProductId\[/code\] and the URL format string \[code\]ProductDetail.aspx?ProductId={0}\[/code\]However, for this case I am not using the GridView control.
 
Back
Top