Solved

Datagrid in visual studio 2003, asp.net

Posted on 2007-12-04
6
1,112 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run time Error 4 47
Connection String 16 57
Need help with building query string 2 19
Checking a checkbox based on SQL DataReader boolean value in ASP.NET(VB) 2 17
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 …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

773 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