I've been reading through the tutorials and forums to see if this is possible or if maybe my approach is wrong. Here's what i am doing.
I am using a pretty simple grid with an id number in the second column. The first column is a checkbox cell. All I want to do is to check the checkbox of say 4 or 5 of the rows and them ask the grid which rows have been selected. Does the grid's selected rows collection maintain this for me or do I have to code this myself to store the key's seperately, which is easy enough to do. But from looking at the various forum threads, it looks like the grid will do this if you allow mulitple row selections. But when I set this and check the selectedrows collection, it is always empty.
This sounds like a VERY common question and approach, but I cannot find the anwser. What I would like to do is something like the following. This doesn't work because the selectedrows(0) is always empty. In fact, when I view just the selectedrows, the count is always 0. So the grid is not keeping track of this for me.
I do have the option turned on to select multiple rows. I can add my own logic to track this, but I think the grid is handling it based on other threads and the sample code below.
I am using a pretty simple grid with an id number in the second column. The first column is a checkbox cell. All I want to do is to check the checkbox of say 4 or 5 of the rows and them ask the grid which rows have been selected. Does the grid's selected rows collection maintain this for me or do I have to code this myself to store the key's seperately, which is easy enough to do. But from looking at the various forum threads, it looks like the grid will do this if you allow mulitple row selections. But when I set this and check the selectedrows collection, it is always empty.
This sounds like a VERY common question and approach, but I cannot find the anwser. What I would like to do is something like the following. This doesn't work because the selectedrows(0) is always empty. In fact, when I view just the selectedrows, the count is always 0. So the grid is not keeping track of this for me.
I do have the option turned on to select multiple rows. I can add my own logic to track this, but I think the grid is handling it based on other threads and the sample code below.
Private Sub dgvLoanRestore_ValueChanged(sender As System.Object, e As System.EventArgs) Handles dgvLoanRestore.ValueChanged
dgvLoanRestore.EndEdit()
Dim selectedRows As New List(Of GridViewDataRowInfo)
Dim item As Object = dgvLoanBackup.SelectedRows(0).DataBoundItem
selectedRows.Clear()
selectedRows.Add(item)
' Recount rows selected (i.e. the number of checked checkboxes in the grid)
lblSelectedRowCount.Text = selectedRows.Count.ToString()
End Sub