Results 1 to 3 of 3

Thread: datagrid, datarows

  1. #1

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591

    Exclamation datagrid, datarows

    Ok, i'm picking up a project for someone else, and its confusing me very badly.

    We have a datagrid, and in the footer of each column, there is a texbox. Whichever row is selected, the values of each item in that row is displayed in the txtboxes in the footer. Kinda see where I'm going? When changes are made to the columns there is another button in the footer called ADD which changes the values of the dataset if the values of the textboxes were changed.

    Here's some code, it looks like a mess to me and I'm highly confused by it.

    Protected Sub OnInsert(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
    Dim drItem As DataRow()
    Dim txtTemp As New TextBox()

    drItem(0) = dsItems.Tables(0).NewRow
    txtTemp = e.Item.FindControl("txtItemAdd")
    drItem(1) = "test"
    txtTemp = e.Item.FindControl("txtPriceAdd")
    drItem(3) = txtTemp.Text
    'txtTemp = e.Item.FindControl("txtQuantityAdd")
    'drItem(4) = txtTemp.Text

    'dsItems.Tables(0).Rows.InsertAt(drItem, 0)
    'DataGrid1.DataSource = dsItems.Tables(0)
    'DataGrid1.DataBind()
    End Sub


    PLEASE HELP! When I click the EDIT button to select the row, i get this error:
    Object reference not set to an instance of an object

    and it highlights the line:
    drItem(0) = dsItems.Tables(0).NewRow

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Can you look to see what is still Nothing? Might be dsItems?

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    How, and where, have you declared dsItems?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width