Subject: index out of range datagrid
Posted By: muchengeti Post Date: 4/21/2006 12:43:42 PM
index out of range must be a non negative and less than trhe size of the collection.
My delectecommand is firing and e.item.itemindex is returning the correct row number, non -ve , the collection, i do not know what collection.

and what is it about hiding the datekey column.

please help assignement due on the 23rd april 2006.
code below/


Dim dr As DataRow
'creating dt on the fly with new dataview
 
         ' Define the columns of the table.
         dt.Columns.Add(new DataColumn("IntegerValue", GetType(Integer)))
         dt.Columns.Add(new DataColumn("StringValue", GetType(String)))
         dt.Columns.Add(new DataColumn("CurrencyValue", GetType(Double)))

------      
'setting the datakey column as the first column
         Dim keys(1) As DataColumn
         keys(0) = dt.Columns(0)
------
datagrid_deletecommand section

         Dim row As DataRow
         row = dt.Rows.Find(ItemsGrid.DataKeys(e.Item.ItemIndex))

         ' Delete the item selected in the DataGrid from the data source.
         If Not row is Nothing Then
         
            dt.Rows.Remove(row)
         
         End If

         ' Save the data source.
         Session("Source") = dt

         ' Create a DataView and bind it to the DataGrid control.
         Dim dv As DataView = New DataView(dt)
         ItemsGrid.DataSource = dv
         ItemsGrid.DataBind()


another datagrid program not working as well
cartview is a dataview

         ' Remove the old entry and clear the row filter.
         CartView.RowFilter = "Item='" & item & "'"
         If CartView.Count > 0 Then
       
            CartView.Delete(0)
         
         End If
         CartView.RowFilter =


depressed/


Go to topic 43076

Return to index page 307
Return to index page 306
Return to index page 305
Return to index page 304
Return to index page 303
Return to index page 302
Return to index page 301
Return to index page 300
Return to index page 299
Return to index page 298