Solved

Datagrid in visual studio 2003, asp.net

Posted on 2007-12-04
6
1,106 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:sfunderwood
Comment Utility
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
Comment Utility
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
Comment Utility
nah there is no equivalent in 1.1, datagrid is the closest thing
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

12 Experts available now in Live!

Get 1:1 Help Now