944,179 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 4588
  • VB.NET RSS
May 4th, 2006
0

need Help in store Datagrid item in an array

Expand Post »
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

VB.NET Syntax (Toggle Plain Text)
  1. Private Sub NextBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextBtn.Click
  2. Dim objItem As DataGridItem
  3. For Each objItem In SKU_Search_DG.Items
  4. ' Ignore invalid items
  5. If objItem.ItemType <> ListItemType.Header And _
  6. objItem.ItemType <> ListItemType.Footer And _
  7. objItem.ItemType <> ListItemType.Pager Then
  8. ' Retrieve the value of the check box
  9. Dim blnChecked As Boolean
  10. blnChecked = CType(objItem.Cells(0).FindControl("grid_CheckBox1"), _
  11. CheckBox).Checked
  12. If blnChecked = True Then
  13. ' add the selected SKU_Id in the array
  14. SKU_ID_Array.Add(objItem.Cells(1).Text.Trim())
  15. 'add_selectedSKU(objItem.Cells(1).Text.Trim()) --- commented out
  16. End If
  17. End If
  18. Next
  19. Response.Redirect("ApplyDiscount.aspx")
  20. End Sub
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Texpert is offline Offline
14 posts
since Jan 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Filling datarow with combos!
Next Thread in VB.NET Forum Timeline: How do I convert a PrintDocument to a Bitmap?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC