Specified Argument out of range error

G

Guest

Hi,

Pls let me how to solve this error "Specified argument out of range"
Pls find the code below and let me know the solution.

Public Class viewcart
Inherits System.Web.UI.Page
Protected WithEvents Cart As System.Web.UI.WebControls.DataGrid
Protected WithEvents Label7 As System.Web.UI.WebControls.Label
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents Image2 As System.Web.UI.WebControls.Image
Protected WithEvents Image1 As System.Web.UI.WebControls.Image
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Dim objTable As New DataTable("Temporary")
Dim CartView As DataView
Protected WithEvents HyperLink9 As System.Web.UI.WebControls.HyperLink
Dim i As Integer
'
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim objRow As DataRow
'
Try
ConSQL.Open()
objTable = sesDT '---- Global DataTable populated by many webpages
----'
CartView = New DataView(objTable)
i = objTable.Rows.Count
'
If objTable.Rows.Count <= 0 Then
Say("Sorry, Shopping Cart is empty.")
End If
'
Do While i < 7
objRow = objTable.NewRow
objTable.Rows.Add(objRow)
i = i + 1
Loop
'
Catch ex As Exception
Say(ex.Message.ToString)
Finally
If ConSQL.State = ConnectionState.Open Then
ConSQL.Close()
End If
End Try
'
If Not IsPostBack Then
BindGrid()
End If
'
End Sub
'
Private Sub BindGrid()
'
Cart.DataSource = CartView
Cart.DataBind()
'
End Sub
'
Private Sub Cart_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles Cart.EditCommand
'
Cart.EditItemIndex = e.Item.ItemIndex
BindGrid()
'
End Sub
'
Private Sub Cart_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles Cart.UpdateCommand
'
Try
'
Dim itemcode As String = e.Item.Cells(0).Text
Dim itemname As String = e.Item.Cells(1).Text
' Dim qtyText As TextBox = e.Item.Cells(2).Controls(0) '--- If I comment
these 2
lines program works with 2 as default qty. Even if I Typecast to
textbox it
throws error. Pls let me know the solution. ---
' Dim qty As String = qtyText.Text
Dim price As Double = e.Item.Cells(3).Text
' Dim Amount As Double = Val(qtyText.Text) * e.Item.Cells(3).Text
Dim Amount As Double = 2 * e.Item.Cells(3).Text
Dim dr As DataRow
'
CartView.RowFilter = "Itemcode='" & itemcode & "'"
If CartView.Count > 0 Then
CartView.Delete(0)
End If
CartView.RowFilter = ""
dr = objTable.NewRow()
dr(0) = itemcode
dr(1) = itemname
dr(2) = 2
dr(3) = price
dr(4) = Amount
objTable.Rows.Add(dr)
Cart.EditItemIndex = -1
BindGrid()
'
Catch ex As Exception
Say(ex.Message)
End Try
'
End Sub
'
Private Sub Cart_CancelCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) handles Cart.CancelCommand
'
Cart.EditItemIndex = -1
BindGrid()
'
End Sub
'
Private Sub Cart_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
Cart.PageIndexChanged
'
If Cart.CurrentPageIndex >= 0 Or Cart.CurrentPageIndex < Cart.PageCount
Then
Cart.CurrentPageIndex = e.NewPageIndex
BindGrid()
End If
'
End Sub
'
End Class



Thanks,

R.Shakthi
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top