473,834 Members | 1,853 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 4311
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
6700
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
2110
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
2606
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
1839
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
3387
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
3189
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
4960
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
2268
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
9646
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
10793
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
10510
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
10548
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
9331
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...
0
6954
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
5794
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4427
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
3
3081
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.