Please Help

G

Guest

Hello All,

The following code give me this error:
Index 3 is not non-negative and below total rows count.

Line 452: Private Sub cboSellers_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cboSellers.SelectedIndexChanged
Line 453: Dim ParentTableView As New
DataView(DsSellers1.Tables("SELLERS"))
Line 454: Dim CurrentRowView As DataRowView =
ParentTableView.Item(Me.cboSellers.SelectedValue)
Line 455:
Line 456: grdSellers.DataSource =
CurrentRowView.CreateChildView("SellersRelation")

Stop at Line 454. I can't firgure out why is it erroring out. I have the
same code for two Datagrid (a master and detail) and it working sometimes. i
feel I'm missing a something. Can someone help on this. I like to get it fix
asap. Thanks in advances!





----------------------------------Code-----------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
If Not IsPostBack Then
'Fill all DataAdapters into DsSellers dataset.
Me.daSellers.Fill(Me.DsSellers1)
Me.daDoc_Type.Fill(Me.DsSellers1)
Me.daOccupancy.Fill(Me.DsSellers1)
Me.daProduct_Code.Fill(Me.DsSellers1)
Me.daProperty_Type.Fill(Me.DsSellers1)
Me.daPurpose.Fill(Me.DsSellers1)

'Data bind all data to their controls.
Me.cboSellers.DataBind()

Dim ParentColumn As New DataColumn
Dim ChildColumn As New DataColumn

ParentColumn =
DsSellers1.Tables("SELLERS").Columns("SELLER_ID")
ChildColumn =
DsSellers1.Tables("DOC_TYPE_LISTING").Columns("SELLER_ID")

Dim drSellers As New DataRelation("SellersRelation",
ParentColumn, ChildColumn)
DsSellers1.Relations.Add(drSellers)

End If

Catch ex As Exception
Response.Write(ex.Message)
Finally
Me.ConnWBOC5177.Close()
Me.ConnWBOC5177.Dispose()
End Try

End Sub

Private Sub cboSellers_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cboSellers.SelectedIndexChanged
Dim ParentTableView As New DataView(DsSellers1.Tables("SELLERS"))
Dim CurrentRowView As DataRowView =
ParentTableView.Item(Me.cboSellers.SelectedValue)

grdSellers.DataSource =
CurrentRowView.CreateChildView("SellersRelation")
grdSellers.DataBind()
End Sub
 
C

Cor Ligthert

MG,

When you want to use the index on a combobox has to be related to the
datasource.

(However probably is your problem that you use the selectedvalue instead of
the selectedindex, probably something in your eyes that does not allow you
to see that)

:)

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top