Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

checbox in gridview on vb.net

Posted on 2014-08-03
2
Medium Priority
?
546 Views
Last Modified: 2014-08-07
Hi Expert,

I like if checkbox check, I need remove a row. Code have a error  'If chkRow.Checked Then' said chkRow need check is null, how i can do it?


 For Each row As GridViewRow In gdView.Rows

                If row.RowType = DataControlRowType.DataRow Then

                    Dim chkRow As CheckBox = TryCast(row.Cells(0).FindControl("chkRemove"), CheckBox)

                    If chkRow.Checked Then

                       Dim hfStudentNumber As HiddenField = DirectCast(row.FindControl("hfStudentNumber"), HiddenField)
                     'remove row hfStudentNumber

Thanks.
0
Comment
Question by:dshi15
2 Comments
 
LVL 15

Accepted Solution

by:
rajeeshmca earned 1000 total points
ID: 40238600
Hi,

As per my understanding, your requirement is to delete multiple roes that are checked in checkbox.

Please find below link which is same as your requirement
http://www.codecomplete4u.com/delete-multiple-rows-gridview-using-checkbox-asp-net/

If you can post your entire code, I can find the issue with your project.

Regards
Rajeesh
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 1000 total points
ID: 40238889
Is the checkbox definitely in first column?

You can change this

  If chkRow.Checked Then

                       Dim hfStudentNumber As HiddenField = DirectCast(row.FindControl("hfStudentNumber"), HiddenField)
                     'remove row hfStudentNumber

to


If Not IsNothing(chkRow) Then
  If chkRow.Checked Then

                       Dim hfStudentNumber As HiddenField = DirectCast(row.FindControl("hfStudentNumber"), HiddenField)
                     'remove row hfStudentNumber
End If
End If


to get rid of the error.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question