Texpert 0 Newbie Poster


can someone help me to code this ?
I have a dynamic datagrid and I want to insert only one column from selected [checkbox] rows in the datagrid into a SQL-Server table.
I've a working code where I call Add_to_DB function within the loop of Datagrid items, which works, but I don't like that, I know I can store the values in an ArrayList and then just make one DB call to insert all the rows in the table. But I am having hard time coding this, I keep on getting null reference error. I know I am doing something stupid.

please help.


Private Sub NextBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextBtn.Click
        Dim objItem As DataGridItem
        For Each objItem In SKU_Search_DG.Items
            ' Ignore invalid items
            If objItem.ItemType <> ListItemType.Header And _
                objItem.ItemType <> ListItemType.Footer And _
                objItem.ItemType <> ListItemType.Pager Then
                ' Retrieve the value of the check box
                Dim blnChecked As Boolean
                blnChecked = CType(objItem.Cells(0).FindControl("grid_CheckBox1"), _
                If blnChecked = True Then
                    ' add the selected SKU_Id in the array
                    'add_selectedSKU(objItem.Cells(1).Text.Trim())  --- commented out
                End If
            End If
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.