|
-
Sep 22nd, 2011, 02:16 AM
#1
Thread Starter
PowerPoster
[RESOLVED] 2 dimensional array question
Hi Guys,
I have a gridview in my asp.net website that and I use vb for the code behind. Each time a row is bound an even called the Gridview_RowDatabound event is fired. So what I am doing is looping through all the cells in that row:
Code:
Private ArrDisbursements(,) As String = New String(,) {}
For c As Integer = 4 To e.Row.Cells.Count - 1
ReDim ArrDisbursements(e.Row.RowIndex, c - 4)
For Each ctl As Control In e.Row.Cells(c).Controls
If TypeOf ctl Is TextBox Then
Dim txtbox As TextBox = CType(ctl, TextBox)
' ArrDisbursements(e.Row.RowIndex, c - 4) = txtbox.Text
End If
Next
Next
Problem here is I need to store Row,Column pair values like this, say there are 2 rows with 3 columns each :
so when row 1 is bound my array must be:
ArrDisbursements(0,1) = 74
ArrDisbursements(0,2) = 75
ArrDisbursements(0,3) = 76
then when row 2 is bound, the above values must be preserved and the next row values must be added:
ArrDisbursements(1,1) = 77
ArrDisbursements(1,2) = 78
ArrDisbursements(1,3) = 79
Problem is I get an error saying redim can only change the rightmost dimension. It would suit my needs to change both dimensions here as my final result will be to total each column in the array. I posted in this forum since it's an array question please help. what other method can i use if arrays don't suit this task
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|