Hi,
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.
TIA
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"), _
CheckBox).Checked
If blnChecked = True Then
' add the selected SKU_Id in the array
SKU_ID_Array.Add(objItem.Cells(1).Text.Trim())
'add_selectedSKU(objItem.Cells(1).Text.Trim()) --- commented out
End If
End If
Next
Response.Redirect("ApplyDiscount.aspx")
End Sub