Solved

Datagrid in visual studio 2003, asp.net

Posted on 2007-12-04
6
1,109 Views
Last Modified: 2012-05-05
Is there a way when a button is clicked, lets say an OK button outside of the datagrid, when clicked to loop thru the datagrid and findout which rows that have a checkbox in it to findout if that checkbox is checked or not. and then assign the remainder rows to a separate datatable to do more work on?
0
Comment
Question by:sfunderwood
  • 2
  • 2
  • 2
6 Comments
 
LVL 10

Accepted Solution

by:
Alpesh Patel earned 250 total points
ID: 20407169
Here you need some tricky things to do

first of all run your page and go to the sourve view
find out the id generated for the checkbox in the column

suppose the id generated is like chkboxgrid_0, chkboxgrid_1 chkboxgrid_2 etc.

no go through the scenario
dim chkbox as CheckBox
for i= 0 to rows.count

chkbox= ctype(me.findcontrol("chckboxgrid_"&i),CheckBox)
access chkbox properties for your use

next
0
 
LVL 22

Assisted Solution

by:RedKelvin
RedKelvin earned 250 total points
ID: 20407208
Hi, you can do something like this, keep in mind that variable 'y', needs to be the index of the checkbox column.
    For x As Integer = 0 To GridView1.Rows.Count - 1

      If CType(GridView1.Rows(x).Cells(y).FindControl("MyCheckbox"), CheckBox).Checked Then

        ' copy row to datatable

      End If

    Next

Open in new window

0
 
LVL 10

Expert Comment

by:Alpesh Patel
ID: 20412557
RedKelvin

you are perfect for sfunderwood's requirement but i thing so FindControl need ID for perticular control
so would your code works perfectly ?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:sfunderwood
ID: 20415782
RedKelvin,
What would the equivalent for a GridView in .net 1.1? Or is there anything. I even thought of using a repeater for this process.
Any more help would be greatly apprecitated.
0
 

Author Closing Comment

by:sfunderwood
ID: 31412707
Here is the solution that I used.
Thanks for all the help!

 Dim dEdit As DataTable = Session("Editableplayers")
        Dim cSelect As CheckBox
        Dim dgi As DataGridItem
        Dim cSerial As Object
        Dim x As Integer
        Dim y As Integer
        For Each dgi In DataGrid1.Items
            cSelect = dgi.FindControl("Selectbox")
            cSerial = dgi.ItemIndex
            x = CInt(cSerial)
            If cSelect.Checked = True Then
               dEdit.Rows(x).Delete()
            End If
        Next
          dEdit.AcceptChanges()
        Session("EditablePlayers") = dEdit.Copy
        Response.Redirect("confirmclonedplayers.aspx")
0
 
LVL 22

Expert Comment

by:RedKelvin
ID: 20448106
nah there is no equivalent in 1.1, datagrid is the closest thing
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

930 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now