473,385 Members | 1,912 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,385 software developers and data experts.

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.Items.Count - 1
Dim item As DataGridItem = myDataGrid.Items.Item(rowindex)
For colindex = 0 To myDataGrid.Columns.Count - 1
Dim itemColumn As DataGridColumn =
myDataGrid.Columns.Item(colindex)
Dim cellValue As Boolean
cellValue = CBool(item.Cells(colindex).Text)
If cellValue = True Then
.......................

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

cellValue = item.Cells(colindex).FindControl(columnId).Checked

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

I saw some of groupers use

((CheckBox)E.Item.FindControl("id")).Checked to get if the box is
checked.

E is variable of DataGridCommandEventArgs, but my e is a
System.Web.UI.ImageClickEventArgs, 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 4256
Hi,

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

Ken
----------------
"gugu" <ji****@yahoo.com> wrote in message
news:a9**************************@posting.google.c om...
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
Dim itemColumn As DataGridColumn =
myDataGrid.Columns.Item(colindex)
Dim cellValue As Boolean
cellValue = CBool(item.Cells(colindex).Text)
If cellValue = True Then
.......................

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

cellValue = item.Cells(colindex).FindControl(columnId).Checked

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

I saw some of groupers use

((CheckBox)E.Item.FindControl("id")).Checked to get if the box is
checked.

E is variable of DataGridCommandEventArgs, but my e is a
System.Web.UI.ImageClickEventArgs, 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.Items.Count - 1
Dim item As DataGridItem = myDataGrid.Items.Item(rowindex)
For colindex = 0 To myDataGrid.Columns.Count - 1
cellValue = CBool(Datagrid1.Item(rowindex, colindex))
If cellValue = True Then

Ken
----------------
"gugu" <ji****@yahoo.com> wrote in message
news:a9**************************@posting.google.c om...
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
Dim itemColumn As DataGridColumn =
myDataGrid.Columns.Item(colindex)
Dim cellValue As Boolean
cellValue = CBool(item.Cells(colindex).Text)
If cellValue = True Then
.......................

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

cellValue = item.Cells(colindex).FindControl(columnId).Checked

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

I saw some of groupers use

((CheckBox)E.Item.FindControl("id")).Checked to get if the box is
checked.

E is variable of DataGridCommandEventArgs, but my e is a
System.Web.UI.ImageClickEventArgs, 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(rindex,cindex) any more, the error is "Item is not a member
of System...Datagrid", it only has grid.Items(index) and this only
returns a cell not the value of this cell.
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:<eF**************@TK2MSFTNGP11.phx.gbl>...
Hi,

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

Ken
----------------
"gugu" <ji****@yahoo.com> wrote in message
news:a9**************************@posting.google.c om...
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
Dim itemColumn As DataGridColumn =
myDataGrid.Columns.Item(colindex)
Dim cellValue As Boolean
cellValue = CBool(item.Cells(colindex).Text)
If cellValue = True Then
.......................

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

cellValue = item.Cells(colindex).FindControl(columnId).Checked

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

I saw some of groupers use

((CheckBox)E.Item.FindControl("id")).Checked to get if the box is
checked.

E is variable of DataGridCommandEventArgs, but my e is a
System.Web.UI.ImageClickEventArgs, 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(rindex,cindex) any more, the error is "Item is not a member
of System...Datagrid", it only has grid.Items(index) and this only
returns a cell not the value of this cell.
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:<eF**************@TK2MSFTNGP11.phx.gbl>...
Hi,

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

Ken
----------------
"gugu" <ji****@yahoo.com> wrote in message
news:a9**************************@posting.google.c om...
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
Dim itemColumn As DataGridColumn =
myDataGrid.Columns.Item(colindex)
Dim cellValue As Boolean
cellValue = CBool(item.Cells(colindex).Text)
If cellValue = True Then
.......................

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

cellValue = item.Cells(colindex).FindControl(columnId).Checked

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

I saw some of groupers use

((CheckBox)E.Item.FindControl("id")).Checked to get if the box is
checked.

E is variable of DataGridCommandEventArgs, but my e is a
System.Web.UI.ImageClickEventArgs, 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
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 (...
2
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...
3
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....
0
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...
1
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
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...
4
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...
10
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...
1
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
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...

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.