I am attempting to assign the imageurl to the image control in the code behind.
I have it working somewhat however, I must not have the code looping correctly because if there is more than one item associated with the IDOrder, the grid displays images correctly unless there are two of the same types in the same IF statement. If there is more than one of the same type in any one IF statement then only the first image will show and the rest will simply display the dreaded X.
Here is my code.
Thank you in advance.
I have it working somewhat however, I must not have the code looping correctly because if there is more than one item associated with the IDOrder, the grid displays images correctly unless there are two of the same types in the same IF statement. If there is more than one of the same type in any one IF statement then only the first image will show and the rest will simply display the dreaded X.
Here is my code.
Protected Sub rgd_OrderItems_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgd_OrderItems.ItemDataBound Dim IDOrder = Request.QueryString("IDOrder") Dim cn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("ETP_OPS_ConnectionString").ToString) cn.Open() Dim SqlCmd As SqlCommand SqlCmd = New SqlCommand("SELECT ImageFilePath FROM vw_Orders_Items WHERE ([IDOrder] = @IDOrder)", cn) SqlCmd.Parameters.Add("@IDOrder", SqlDbType.NVarChar, 36).Value = IDOrder Dim ImageFilePath = CType(SqlCmd.ExecuteScalar, String) cn.Close() If TypeOf e.Item Is GridDataItem Then For Each item As GridDataItem In rgd_OrderItems.Items 'Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) Dim img As Image = DirectCast(item.FindControl("ImageFilePath"), Image) If ImageFilePath.Contains(".jpg") _ Or ImageFilePath.Contains(".jpeg") _ Or ImageFilePath.Contains(".gif") _ Or ImageFilePath.Contains(".png") Then img.ImageUrl = ImageFilePath ElseIf ImageFilePath Like ("*.doc*") Then img.ImageUrl = "../../images/icon_word.gif" ElseIf ImageFilePath Like ("*.pdf*") Then img.ImageUrl = "../../images/icon_pdf.gif" Else img.ImageUrl = "../../images/icon_unknown.gif" End If 'item("ImageFilePath").Attributes.Add("onclick", "OPenPopuP('" + ImageFilePath + "');") Next End IfThank you in advance.