need Help in store Datagrid item in an array

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2006
Posts: 14
Reputation: Texpert is an unknown quantity at this point 
Solved Threads: 0
Texpert's Avatar
Texpert Texpert is offline Offline
Newbie Poster

need Help in store Datagrid item in an array

 
0
  #1
May 4th, 2006
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

  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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC