Retrieving Images in Sql Server

Results 1 to 2 of 2

Thread: Retrieving Images in Sql Server

  1. #1
    Join Date
    Dec 1969

    Default Retrieving Images in Sql Server

    Hi Guys,<BR><BR>How do I get an image from an MS Sql Table.<BR>I have a datagrid with three columns.<BR>ImgId Int<BR>ImgDesc Varchar<BR>Img Image<BR>In my code I have:<BR> Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles DataGrid1.ItemDataBound<BR> Dim img As System.Web.UI.WebControls.Image<BR> If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then<BR> img = CType(e.Item.Cells(0).Controls(0), System.Web.UI.WebControls.Image) &#060;-- error on this line<BR> img.ImageUrl = "ImagesGetImage.aspx?id=" & e.Item.Cells(2).Text<BR> End If<BR> End Sub<BR>But I get an error of:<BR>"Specified argument was out of the range of valid values. Parameter name: index"<BR><BR>Any Ideas?<BR><BR>Best Regards,<BR><BR>Steve Wilson. <BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Retrieving Images in Sql Server

    I think you want to do something like this: (Pardon my VB)<BR><BR>img = new Image() <BR>img.ImageUrl = "ImagesGetImage.aspx?id=" & e.Item.Cells(2).Text <BR>e.Item.Cells(2).Text = ""<BR>e.Item.Cells(2).Controls.Add(img)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts