Solved

Datagrid in visual studio 2003, asp.net

Posted on 2007-12-04
6
1,122 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

632 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