473,811 Members | 3,057 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 4308
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
9726
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
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10647
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...
1
10395
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
5553
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4338
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3017
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.