473,327 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Unable to Access the Checkbox in the dynamic grid view

1
Hi ,

I have a problem hope someone can help.

I have created a dynamic view which contains a gridview. This gridview contains a check box column in the Template Field with the help of ITemplate interface.
Now the prblm is I'm not able to access this check box . I am using

CheckBox chkSel = (CheckBox)gvRows.Cells[5].FindControl("ckh");

to find the check box but 'chkSel' is always returning null.This check box is in every row of the grid.

Depending on the checkbox selected it should perform some operations by a button click.

this is code which should be there in the button click.


Expand|Select|Wrap|Line Numbers
  1.  foreach (View vw in TabMultiView.Views)
  2.         {
  3.  
  4.            GridView gv = (GridView)vw.Controls[1];
  5.  
  6.            foreach (GridViewRow gvRows in gv.Rows)
  7.             {
  8.                 CheckBox chkSel = (CheckBox)gvRows.Cells[5].FindControl("ckh");
  9.         if (chkSel.Checked)
  10.                    {
  11.                         string chkStatus = "True";
  12.  
  13.                 // some functions are done here..
  14.                     }
  15.  
  16.         }
  17.  
  18.     }
Nov 23 '09 #1
1 2406
Frinavale
9,735 Expert Mod 8TB
It should be:

CheckBox chkSel = (CheckBox)aSpecificGridViewRow.FindControl("ckh");


You cannot get a single CheckBox from all of the GridViewRows.. if you want 1 checkbox then you have to get it from 1 GridViewRow.

If you want all of the CheckBoxes from all of the GridViewRows then you need to loop through the GridViewRows and get the CheckBox from each row.

-Frinny
Nov 25 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
0
by: andrei | last post by:
Hi Group, I have a checkbox column in a web datagrid which is related to a "Product in stock" property. The grid is in view mode, so the user can't (and shouldn't) change anything in the grid....
2
by: Ing. Rajesh Kumar | last post by:
Hi everybody I have a problem reading the content of a cell. When i use AutogenerateColumns = True or when i use <asp:BoundColumn DataField="COLUMN1" HeaderText="COLUMN1"/> then i can simply read...
1
by: Harry Devine | last post by:
I have a DataGrid that is configured to use the Edit/Update/Cancel concept correctly. My grid shows values from 5 database fields. I only need to update that last 4 fields. The last field is a...
13
by: Chris Thunell | last post by:
I have created several grids dynamically and have added them to different HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page...
1
by: Ramakrishnan Nagarajan | last post by:
Hi, I have two checkboxes in each row of a grid. One for Modify and another one for View. If I click Modify the View should get automatically checked and should be disabled. Earlier I did this in...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
20
by: Deano | last post by:
Just looking at C Sharp to see if it might be worth my while learning something new. Has anyone here tried a .NET language and tried to replicate a existing Access app? I would be interested to...
2
by: Smokey Grindle | last post by:
I have the following on my page... a link button that will send the command name "use" to the command handler and a grid view with the following columns 0 - Template column - just a checkbox...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.