Hi,
Not sure this is the right place to ask my question but i will try.
I have a dg that gets populated from the db. I have an image column that received a default -nopict.gif if the db ad_image field is empty. If it isn't empty then the dg shows a thumbnail of the image. Everything till here works great.
Now i have added an option that the user can upload a htm/l file. If in the db the ad_image field contains a htm/l extension then i want the dg to display the image -html.gif from the image file. I have no idea how to write my code to do that.
Thanks in advance.
Below is my aspx.
vb code:
Sub fillTable()
If Page.IsPostBack Then
Add_AD.Visible = True
Dim ad_id As String
Dim u_id As String
u_id = txtUID.Value.Trim
ad_id = txtAdId.Value.Trim
cmd = oConn.CreateCommand
cmd.CommandText = "select *,CASE AD_IMAGE WHEN '' THEN 'nopict.gif' ELSE AD_IMAGE END AS AD_IMGNAME, 'adDetail.aspx?sid=' + @sid + '&ad_id=' + CAST(ad_id AS NVARCHAR(16))+ '&sub_id=' + CAST(sub_id AS NVARCHAR(16))+ '&cat_id=' + CAST(cat_id AS NVARCHAR(16)) AS url_str FROM ybay_mdb...ads WHERE ad_poster like '%'+@U_ID+'%' AND AD_ID like '%'+@AD_ID+'%'"
cmd.Parameters.Add("@U_ID", u_id)
cmd.Parameters.Add("@AD_ID", ad_id)
cmd.Parameters.Add("@sid", sid)
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable("ADS")
da.Fill(dt)
DataGrid1.DataSource = dt
DataGrid1.DataBind()
If dt.Rows.Count = 0 Then
DataGrid1.Visible = False
Label1.Visible = True
Else
DataGrid1.Visible = True
Label1.Visible = False
End If
'oConn.Open()
'Dim dr As SqlDataReader
'dr = cmd.ExecuteReader
'Do While dr.Read
' AD_IMGNAME = dr.Item("AD_IMGNAME")
'Dim s0 As String
's0 = AD_IMGNAME.Split(".")(1)
'If s0 = "html" Or s0 = "htm" Then
' AD_IMGNAME = "html.gif"
' Response.Write(AD_IMGNAME)
' End If
'Loop
'oConn.Close()
End If
End Sub
Sub doPaging(ByVal s As Object, ByVal e As DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
fillTable()
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
fillTable()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Redirect("Manage_Users.aspx?sid=" & sid)
End Sub
The aspx dg part where i load the image:
<ItemTemplate>
<Img src="http://www.mysite.co.il/images/<%#Container.DataItem("AD_IMGNAME") %>" id="img" height="50" width="50">
</ItemTemplate>