Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Why is this code not working? :(


Message #1 by artimahendra@s... on Fri, 10 Jan 2003 13:23:47
Hi all

please help me solve this problem that is making me mad.

i have a grid with a template col that has a check box. i wish to create a 
string of teh key values for teh rows that have been checked by the user. 
with the help of the message on this forum - i got an idea of teh code 
from the articles on the MS website. but it is not working...

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles Button1.Click



        ' Walk the grid looking for selected rows

        Dim i As Integer = 0
        Dim cb As CheckBox
        Dim dgi As DataGridItem
        Dim MCode As Integer
        Dim str As String


        For Each dgi In dgMachines.Items
            cb = CType(dgi.FindControl("chkDel"), CheckBox)
            If cb.Checked Then
                ' Determine the key of the selected record ... 
                MCode = CType(dgMachines.DataKeys(i), Integer)
                ' ... get a pointer to the corresponding dataset record ...
                str = str + MCode.ToString

            End If
            i += 1
        Next
End Sub

**************
when i run the app - upon click i get the error that
Object reference not set to an instance of an object. 

What is wrong??
please help:(

thanks 
regards
Arti Mahendra Sharma


  Return to Index