Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Problem with Datagrid ItemDatabound !!!!

Reply
Thread Tools

Problem with Datagrid ItemDatabound !!!!

 
 
Michael Persaud
Guest
Posts: n/a
 
      07-14-2004
Hi All,

Can someone please show me where i am wrong

I am tring to have the path (from sql) of images to be bound to their
picture box.

So far i am getting the last record from the DB being placed in all the
images and not thier respective records.

The idea was to loop through the datagrid souce table and then do a look up
and load the images


PLEASE ANY HELP WOULD BE APPRECIATED

Thanks
MP


Sub DataGridProduct_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGridProduct.ItemDataBound

GetImageRowsX(e)
End Sub

Sub GetImageRowsX(ByVal e) ' As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGridProduct.ItemDataBound
dgSource = DataGridProduct.DataSource
Dim catid, i, cCount As Integer
Dim ImagePath As String
cCount = dgSource.tables(0).rows.count
Dim nIndx As Integer
Label1.Text = ""
Dim dr As SqlDataReader
Dim img As New Image

For i = 0 To cCount - 1
nIndx = i
catid = dgSource.tables(0).rows(nIndx)(0)

ImagePath = ""

Dim cmd As New SqlCommand _
("select categoryid,path from categories where categoryid = " &
catid, SQLCATCON)
SQLCATCON.Close()
SQLCATCON.Open()
dr = cmd.ExecuteReader()
dr.Read()
If Not dr.GetValue(1) Is DBNull.Value Then
ImagePath = dr.GetValue(1)

If e.Item.ItemType = ListItemType.AlternatingItem Or
e.Item.ItemType = ListItemType.Item Then
'img = CType(e.Item.Cells(2).Controls(1),
System.Web.UI.WebControls.Image)
img = CType(e.Item.Cells(2).FindControl("ImageBox"),
System.Web.UI.WebControls.Image)
img.ImageUrl = "images/" + ImagePath
e.Item.Cells(2).Controls.Add(img)
img.ToolTip = e.Item.Cells(1).Text
Else

End If
End If
dr.Close()
'Label1.Text = Label1.Text + catid.ToString + ImagePath
Next

End Sub




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid : e.Item.ItemType=Pager not executed in ItemDataBound RJN ASP .Net 1 12-24-2006 10:57 PM
DataGrid, ItemDataBound =?Utf-8?B?Sm9u?= ASP .Net 1 01-13-2005 10:07 PM
ItemDataBound event of DataGrid Dave ASP .Net 2 10-07-2004 02:54 PM
DataGrid - ItemDataBound =?iso-8859-1?Q?Andr=E9_Almeida_Maldonado?= ASP .Net 1 07-07-2004 03:02 AM
Datagrid losing changes made in ItemDataBound Tony Middleton ASP .Net 0 04-22-2004 07:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57