PDA

View Full Version : Datagrid Event Problems


dan
06-10-2003, 03:51 AM
I'm having some trouble with datagrid events on this page:
www.freejollies.com/picalbum.aspx

You'll notice that there is an error if you click on any of the items in the 'Pictures' datagrid. However you can change 'Categories' on the right sucessfully. This works fine on my server at home (.NET 1.1, IIS 5) and am puzzled as to why it won't here. I've traced the problem to this chunk of code:

'This handles the click event for datagrid items
Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged
PicOps.bindcategory(CInt(Session.Item("ncat")))
Dim index As String, key As String
index = DataGrid1.SelectedIndex.ToString
key = DataGrid1.DataKeys(index).ToString()
PicOps.imagebind(key)
'Here's where I see the problem: the dataview set in the imagebind sub (see below) is not returning any rows. It returns the correct on on my configuration at home
databinder()
End Sub

Sub imagebind(ByVal key As String)
'This sub is being called from a component 'PicOps'
oDBAdapt.Fill(DsPics1)
DataView1.RowFilter = "ID" & "=" & key
imagebind = DataView1.Count
End Sub

'Here's the databinder sub too
Sub databinder()
lblName.Text = PicOps.DataView1.Item(0).Item(3)
lblQuip.Text = PicOps.DataView1.Item(0).Item(5)
Image1.ImageUrl = PicOps.DataView1.Item(0).Item(1)
Image1.DataBind()
lblName.DataBind()
lblQuip.DataBind()
DataGrid1.DataBind()
End Sub


Thanks for any help or suggestions you can provide.

bruce
06-11-2003, 10:25 AM
THe error you are seeing basically means that the dataset is no longer available.

Try refilling the dataset


[b]quote:Originally posted by dan

I'm having some trouble with datagrid events on this page:
www.freejollies.com/picalbum.aspx

You'll notice that there is an error if you click on any of the items in the 'Pictures' datagrid. However you can change 'Categories' on the right sucessfully. This works fine on my server at home (.NET 1.1, IIS 5) and am puzzled as to why it won't here. I've traced the problem to this chunk of code:

'This handles the click event for datagrid items
Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged
PicOps.bindcategory(CInt(Session.Item("ncat")))
Dim index As String, key As String
index = DataGrid1.SelectedIndex.ToString
key = DataGrid1.DataKeys(index).ToString()
PicOps.imagebind(key)
'Here's where I see the problem: the dataview set in the imagebind sub (see below) is not returning any rows. It returns the correct on on my configuration at home
databinder()
End Sub

Sub imagebind(ByVal key As String)
'This sub is being called from a component 'PicOps'
oDBAdapt.Fill(DsPics1)
DataView1.RowFilter = "ID" & "=" & key
imagebind = DataView1.Count
End Sub

'Here's the databinder sub too
Sub databinder()
lblName.Text = PicOps.DataView1.Item(0).Item(3)
lblQuip.Text = PicOps.DataView1.Item(0).Item(5)
Image1.ImageUrl = PicOps.DataView1.Item(0).Item(1)
Image1.DataBind()
lblName.DataBind()
lblQuip.DataBind()
DataGrid1.DataBind()
End Sub


Thanks for any help or suggestions you can provide.


</blockquote id="quote"></font id="quote">