473,548 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to Access the Checkbox in the dynamic grid view

1 New Member
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)gvRow s.Cells[5].FindControl("c kh");

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 2413
Frinavale
9,735 Recognized Expert Moderator Expert
It should be:

CheckBox chkSel = (CheckBox)aSpec ificGridViewRow .FindControl("c kh");


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
7893
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 header of the datagrid in the "ItemDataBound" method of the grid. However, once, they are added in the grid, i seem to lose the event handler for the...
0
3091
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. What I need is to show a "ReadOnly" checkbox in the grid, but not a disabled one (grayed out). I'm using a template column and the only property...
2
1318
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 the content of a cell in the OnItemDataBound method using the following code : For j = 0 To DT.Columns.Count - 1 If e.Item.Cells(j).Text =...
1
3772
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 Yes/No value in Access. Using the OleDbCommand, if I do not consider the Yes/No field, the ExecuteNonQuery command, using my UPDATE SQL statement,...
13
3653
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 first starts, but when I click on a button, and the page comes back, my dynamically created grid and controls are not visible. Any thoughts? ...
1
5889
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 server side and thing was working fine. But when the user clicks the last row in the grid and make the modify in that row to be checked the focus...
52
9925
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 2005, and, since he already has licenses for Office Pro 2002, he wants to upgrade to that. I've been saying that we need to upgrade to Access...
20
2080
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 hear how any stories about this and in particular how one deals with not having subforms - can you get a third-party control to fill that gap?
2
2799
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 (asp.net control) 1 - Bound column - DisplayName from data table the checkbox is just a template i made by placeing an asp.net control into the item...
0
7512
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7951
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6036
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5362
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3475
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.