473,811 Members | 2,717 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get a specific check box cell value in datagrid

Hi

I have a datagrid which has 20 rows and 20 columns, 15 of 20 columns
are checkboxs and their headertexts, datafields are dynamic. I need to
loop through the whole page to see if the specific check box cell is
checked or not. The code is as follows:

For rowindex = 0 To myDataGrid.Item s.Count - 1
Dim item As DataGridItem = myDataGrid.Item s.Item(rowindex )
For colindex = 0 To myDataGrid.Colu mns.Count - 1
Dim itemColumn As DataGridColumn =
myDataGrid.Colu mns.Item(colind ex)
Dim cellValue As Boolean
cellValue = CBool(item.Cell s(colindex).Tex t)
If cellValue = True Then
............... ........

Because the cell is check box so "item.Cells(col index).Text" is a
invalid format. I tried another way:

cellValue = item.Cells(coli ndex).FindContr ol(columnId).Ch ecked

The error is "Checked is not a member of Control..."

I saw some of groupers use

((CheckBox)E.It em.FindControl( "id")).Chec ked to get if the box is
checked.

E is variable of DataGridCommand EventArgs, but my e is a
System.Web.UI.I mageClickEventA rgs, so this way doesn't apply to
mydatagrid neither.

I really feel inconvenient that in Visual Studio.NET the cell only has
Text property to get value, it should has Value property and
Value.GetType to decide which value type this cell contains such as
string, integer, boolean?
Any help will be greatly appreciated.
Nov 20 '05 #1
4 4310
Hi,

For rowindex = 0 To myDataGrid.Item s.Count - 1
Dim item As DataGridItem = myDataGrid.Item s.Item(rowindex )
For colindex = 0 To myDataGrid.Colu mns.Count - 1
cellValue = CBool(Datagrid1 .Item(rowindex, colindex))
If cellValue = True Then

Ken
----------------
"gugu" <ji****@yahoo.c om> wrote in message
news:a9******** *************** ***@posting.goo gle.com...
Hi

I have a datagrid which has 20 rows and 20 columns, 15 of 20 columns
are checkboxs and their headertexts, datafields are dynamic. I need to
loop through the whole page to see if the specific check box cell is
checked or not. The code is as follows:

For rowindex = 0 To myDataGrid.Item s.Count - 1
Dim item As DataGridItem = myDataGrid.Item s.Item(rowindex )
For colindex = 0 To myDataGrid.Colu mns.Count - 1
Dim itemColumn As DataGridColumn =
myDataGrid.Colu mns.Item(colind ex)
Dim cellValue As Boolean
cellValue = CBool(item.Cell s(colindex).Tex t)
If cellValue = True Then
............... ........

Because the cell is check box so "item.Cells(col index).Text" is a
invalid format. I tried another way:

cellValue = item.Cells(coli ndex).FindContr ol(columnId).Ch ecked

The error is "Checked is not a member of Control..."

I saw some of groupers use

((CheckBox)E.It em.FindControl( "id")).Chec ked to get if the box is
checked.

E is variable of DataGridCommand EventArgs, but my e is a
System.Web.UI.I mageClickEventA rgs, so this way doesn't apply to
mydatagrid neither.

I really feel inconvenient that in Visual Studio.NET the cell only has
Text property to get value, it should has Value property and
Value.GetType to decide which value type this cell contains such as
string, integer, boolean?
Any help will be greatly appreciated.

Nov 20 '05 #2
Hi,

For rowindex = 0 To myDataGrid.Item s.Count - 1
Dim item As DataGridItem = myDataGrid.Item s.Item(rowindex )
For colindex = 0 To myDataGrid.Colu mns.Count - 1
cellValue = CBool(Datagrid1 .Item(rowindex, colindex))
If cellValue = True Then

Ken
----------------
"gugu" <ji****@yahoo.c om> wrote in message
news:a9******** *************** ***@posting.goo gle.com...
Hi

I have a datagrid which has 20 rows and 20 columns, 15 of 20 columns
are checkboxs and their headertexts, datafields are dynamic. I need to
loop through the whole page to see if the specific check box cell is
checked or not. The code is as follows:

For rowindex = 0 To myDataGrid.Item s.Count - 1
Dim item As DataGridItem = myDataGrid.Item s.Item(rowindex )
For colindex = 0 To myDataGrid.Colu mns.Count - 1
Dim itemColumn As DataGridColumn =
myDataGrid.Colu mns.Item(colind ex)
Dim cellValue As Boolean
cellValue = CBool(item.Cell s(colindex).Tex t)
If cellValue = True Then
............... ........

Because the cell is check box so "item.Cells(col index).Text" is a
invalid format. I tried another way:

cellValue = item.Cells(coli ndex).FindContr ol(columnId).Ch ecked

The error is "Checked is not a member of Control..."

I saw some of groupers use

((CheckBox)E.It em.FindControl( "id")).Chec ked to get if the box is
checked.

E is variable of DataGridCommand EventArgs, but my e is a
System.Web.UI.I mageClickEventA rgs, so this way doesn't apply to
mydatagrid neither.

I really feel inconvenient that in Visual Studio.NET the cell only has
Text property to get value, it should has Value property and
Value.GetType to decide which value type this cell contains such as
string, integer, boolean?
Any help will be greatly appreciated.

Nov 20 '05 #3
Thanks, Ken.

But I used Visual Studio.NET, seems it doesn't support
grid.Item(rinde x,cindex) any more, the error is "Item is not a member
of System...Datagr id", it only has grid.Items(inde x) and this only
returns a cell not the value of this cell.
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message news:<eF******* *******@TK2MSFT NGP11.phx.gbl>. ..
Hi,

For rowindex = 0 To myDataGrid.Item s.Count - 1
Dim item As DataGridItem = myDataGrid.Item s.Item(rowindex )
For colindex = 0 To myDataGrid.Colu mns.Count - 1
cellValue = CBool(Datagrid1 .Item(rowindex, colindex))
If cellValue = True Then

Ken
----------------
"gugu" <ji****@yahoo.c om> wrote in message
news:a9******** *************** ***@posting.goo gle.com...
Hi

I have a datagrid which has 20 rows and 20 columns, 15 of 20 columns
are checkboxs and their headertexts, datafields are dynamic. I need to
loop through the whole page to see if the specific check box cell is
checked or not. The code is as follows:

For rowindex = 0 To myDataGrid.Item s.Count - 1
Dim item As DataGridItem = myDataGrid.Item s.Item(rowindex )
For colindex = 0 To myDataGrid.Colu mns.Count - 1
Dim itemColumn As DataGridColumn =
myDataGrid.Colu mns.Item(colind ex)
Dim cellValue As Boolean
cellValue = CBool(item.Cell s(colindex).Tex t)
If cellValue = True Then
............... ........

Because the cell is check box so "item.Cells(col index).Text" is a
invalid format. I tried another way:

cellValue = item.Cells(coli ndex).FindContr ol(columnId).Ch ecked

The error is "Checked is not a member of Control..."

I saw some of groupers use

((CheckBox)E.It em.FindControl( "id")).Chec ked to get if the box is
checked.

E is variable of DataGridCommand EventArgs, but my e is a
System.Web.UI.I mageClickEventA rgs, so this way doesn't apply to
mydatagrid neither.

I really feel inconvenient that in Visual Studio.NET the cell only has
Text property to get value, it should has Value property and
Value.GetType to decide which value type this cell contains such as
string, integer, boolean?
Any help will be greatly appreciated.

Nov 20 '05 #4
Thanks, Ken.

But I used Visual Studio.NET, seems it doesn't support
grid.Item(rinde x,cindex) any more, the error is "Item is not a member
of System...Datagr id", it only has grid.Items(inde x) and this only
returns a cell not the value of this cell.
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message news:<eF******* *******@TK2MSFT NGP11.phx.gbl>. ..
Hi,

For rowindex = 0 To myDataGrid.Item s.Count - 1
Dim item As DataGridItem = myDataGrid.Item s.Item(rowindex )
For colindex = 0 To myDataGrid.Colu mns.Count - 1
cellValue = CBool(Datagrid1 .Item(rowindex, colindex))
If cellValue = True Then

Ken
----------------
"gugu" <ji****@yahoo.c om> wrote in message
news:a9******** *************** ***@posting.goo gle.com...
Hi

I have a datagrid which has 20 rows and 20 columns, 15 of 20 columns
are checkboxs and their headertexts, datafields are dynamic. I need to
loop through the whole page to see if the specific check box cell is
checked or not. The code is as follows:

For rowindex = 0 To myDataGrid.Item s.Count - 1
Dim item As DataGridItem = myDataGrid.Item s.Item(rowindex )
For colindex = 0 To myDataGrid.Colu mns.Count - 1
Dim itemColumn As DataGridColumn =
myDataGrid.Colu mns.Item(colind ex)
Dim cellValue As Boolean
cellValue = CBool(item.Cell s(colindex).Tex t)
If cellValue = True Then
............... ........

Because the cell is check box so "item.Cells(col index).Text" is a
invalid format. I tried another way:

cellValue = item.Cells(coli ndex).FindContr ol(columnId).Ch ecked

The error is "Checked is not a member of Control..."

I saw some of groupers use

((CheckBox)E.It em.FindControl( "id")).Chec ked to get if the box is
checked.

E is variable of DataGridCommand EventArgs, but my e is a
System.Web.UI.I mageClickEventA rgs, so this way doesn't apply to
mydatagrid neither.

I really feel inconvenient that in Visual Studio.NET the cell only has
Text property to get value, it should has Value property and
Value.GetType to decide which value type this cell contains such as
string, integer, boolean?
Any help will be greatly appreciated.

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
6699
by: VR | last post by:
I am trying to embed a check box into a FlexGrid's cell, but having a problem when I start scrolling the grid. Here is my MyCheckBox class... class MyCheckBox : CheckBox { void Init ( AxMSFlexGridLib.AxMSFlexGrid oGrid,
2
2107
by: michael Schindler | last post by:
How i can set in a datagrid in c# widows forms in a specifig cell example Row 3 column 4 a specifig data for example "Michael"? I want after the user give in a cell in my datagrid additionally datas set in the same row but in a other column but automaticly. Is that possible an how I can realize that? thanks
3
2605
by: Michael Schindler | last post by:
Hello NG How I can delete a specific cell in my Datagrid. I would like if the user is in the column 6 the value changed, after automaticly the value in the column 7 in the same row to delete. Thanks
0
1837
by: Empire City | last post by:
I have an ASP.NET form with a DataGrid and Button. I want to put a RadioButtonList in a DataGrid cell. I bind it to an ArrayList which has a ListItem in the cell. The display part works fine. I then check some boxes and hit the submit button. I can't seem to get the value that is selected on the RadioButton List. I don't want to use the EditTemplate thing I just want to click on the radiobutton and submit the form. I also don't want to do...
1
3385
by: ywchan | last post by:
I would like to make some of the rows in the datagrid read only according to certain condition. How can I make some of the rows editable while others read only in a datagrid? Thanks!
2
3186
by: Daniel Walzenbach | last post by:
Hi, I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchTopQuestionsAboutASPNETDataGridServerControl.asp, Selecting Rows by Clicking Anywhere). Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _ ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
4
908
by: gugu | last post by:
Hi I have a datagrid which has 20 rows and 20 columns, 15 of 20 columns are checkboxs and their headertexts, datafields are dynamic. I need to loop through the whole page to see if the specific check box cell is checked or not. The code is as follows: For rowindex = 0 To myDataGrid.Items.Count - 1 Dim item As DataGridItem = myDataGrid.Items.Item(rowindex) For colindex = 0 To myDataGrid.Columns.Count - 1
10
4957
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than the column order of the datatable). I also allow the user to click on a column header to sort the datagrid by that column. I need to identify the row and column in the datatable when the user clicks on a cell in the datagrid. Using the...
1
2267
by: Gidi | last post by:
Hi, Is it possible to Disable editing of one specific cell in one specific row in dataGrid? Thanks, Gidi.
2
2861
by: Peter | last post by:
ASP.NET 2003 In the DataGrid how do I select current cell value in the dropdown box when I click on the edit link, currently when I click on the edit link in the DataGrid the dropdown box appears in the cell, but allways the first item in the dropdown box is shown not the current cell value? How do I make the current value in the cell automaticaly be selected in the dropdown box.
0
9728
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10648
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10389
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10402
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10135
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9205
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7670
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6890
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.