Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > Index 2 is not non-negative and below total rows count.
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 1st March 03:59
mg
External User
 
Posts: 1
Default Index 2 is not non-negative and below total rows count.



Hello All,

I'm getting this error on a ASP .NET apps:

Index 2 is not non-negative and below total rows count.

Line 443:
Line 444: Dim ParentTableView As New
DataView(DsSellers1.Tables("SELLERS"))
Line 445: Dim CurrentRowView As DataRowView =
ParentTableView(Me.cboSellers.SelectedValue)
Line 446:
Line 447: grdSellers.DataSource =
CurrentRowView.CreateChildView("SellersRelation")

Stop at Line 445. Here is my source code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
If Not Page.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()
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 ParentColumn As DataColumn
Dim ChildColumn As DataColumn

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

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

Dim ParentTableView As New DataView(DsSellers1.Tables("SELLERS"))
Dim CurrentRowView As DataRowView =
ParentTableView(Me.cboSellers.SelectedValue)

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

Can someone help me? I just want to able find related data from the
DropDownList control to the Datagrid use DataRelation object. The Datagrid
will be using it's own queries for Select, Insert, Delete, Update.
  Reply With Quote


 


2 2nd March 18:05
marina
External User
 
Posts: 1
Default Index 2 is not non-negative and below total rows count.



You are trying to access a row that does not exist. You know your code and
data - up to you to figure out why a row that you expect to be there is not.

Most likely it is because you are only retrieving data the first time the
page is loaded in your If statement - and not during postback when you need
it.
  Reply With Quote


 


Reply


Thread Tools
Display Modes




666