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

CheckBoxes in DataGrid

The first column of a DataGrid has a CheckBox for all the rows. I want
that when users check a CheckBox, the BackColor of that entire row in
the DataGrid should change to a different color. To implement this, if
I am not mistaken, I HAVE TO post the Form first i.e. set the
AutoPostBack property of the CheckBox to True. Without posting the
Form, I don't think the BackColor of the checked row can be changed
using ASP.NET, isn't it?

Of course, it can be done using some client side script like JavaScript
but to do it using ASP.NET, I have to post the Form first, isn't it?

Dec 3 '06 #1
7 2479
Yesterday, I done a Google search for the same thing

If you go to http://www.google.com & search for

"CheckListBox", "VB.NET" (with quotes & comma) you will find many examples
of what you are looking for
<rn**@rediffmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
The first column of a DataGrid has a CheckBox for all the rows. I want
that when users check a CheckBox, the BackColor of that entire row in
the DataGrid should change to a different color. To implement this, if
I am not mistaken, I HAVE TO post the Form first i.e. set the
AutoPostBack property of the CheckBox to True. Without posting the
Form, I don't think the BackColor of the checked row can be changed
using ASP.NET, isn't it?

Of course, it can be done using some client side script like JavaScript
but to do it using ASP.NET, I have to post the Form first, isn't it?

Dec 3 '06 #2
I am not looking out for a code snippet to change the BackColor of a
row in the DataGrid which is checked; I have already succeeded in doing
that but I did it by setting the AutoPostBack property of the
CheckBoxes in the DataGrid to True. In other words, I am highlighting
the checked row/s using ASP.NET.

What I would like to know is can the same functionality be added to the
CheckBoxes by setting the AutoPostBack property of the CheckBoxes in
the DataGrid to False. I wouldn't like to use JavaScript (or any other
client-side script) to do that & prefer doing this using ASP.NET.

Even I had a look at a number of articles which show how to do this but
all the articles I have come across set AutoPostBack=True for the
CheckBoxes. Did you find any articles which does this by setting
AutoPostBack=False?
Newbie Coder wrote:
Yesterday, I done a Google search for the same thing

If you go to http://www.google.com & search for

"CheckListBox", "VB.NET" (with quotes & comma) you will find many examples
of what you are looking for
<rn**@rediffmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
The first column of a DataGrid has a CheckBox for all the rows. I want
that when users check a CheckBox, the BackColor of that entire row in
the DataGrid should change to a different color. To implement this, if
I am not mistaken, I HAVE TO post the Form first i.e. set the
AutoPostBack property of the CheckBox to True. Without posting the
Form, I don't think the BackColor of the checked row can be changed
using ASP.NET, isn't it?

Of course, it can be done using some client side script like JavaScript
but to do it using ASP.NET, I have to post the Form first, isn't it?
Dec 3 '06 #3
Hello,

Well i'm afraid brother! but you have to use client side script to
fulfil your requirement.

In my opinion there are only two possibilities:

1. Post back & change gridrow color
2. Use a client side script

Unfortunately i could not think of any other way to change gridrow's
color.

Regards,
Mohsin Rizvi

rn**@rediffmail.com wrote:
I am not looking out for a code snippet to change the BackColor of a
row in the DataGrid which is checked; I have already succeeded in doing
that but I did it by setting the AutoPostBack property of the
CheckBoxes in the DataGrid to True. In other words, I am highlighting
the checked row/s using ASP.NET.

What I would like to know is can the same functionality be added to the
CheckBoxes by setting the AutoPostBack property of the CheckBoxes in
the DataGrid to False. I wouldn't like to use JavaScript (or any other
client-side script) to do that & prefer doing this using ASP.NET.

Even I had a look at a number of articles which show how to do this but
all the articles I have come across set AutoPostBack=True for the
CheckBoxes. Did you find any articles which does this by setting
AutoPostBack=False?
Newbie Coder wrote:
Yesterday, I done a Google search for the same thing

If you go to http://www.google.com & search for

"CheckListBox", "VB.NET" (with quotes & comma) you will find many examples
of what you are looking for
<rn**@rediffmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
The first column of a DataGrid has a CheckBox for all the rows. I want
that when users check a CheckBox, the BackColor of that entire row in
the DataGrid should change to a different color. To implement this, if
I am not mistaken, I HAVE TO post the Form first i.e. set the
AutoPostBack property of the CheckBox to True. Without posting the
Form, I don't think the BackColor of the checked row can be changed
using ASP.NET, isn't it?
>
Of course, it can be done using some client side script like JavaScript
but to do it using ASP.NET, I have to post the Form first, isn't it?
>
Dec 4 '06 #4
nil

Mohsin Rizvi wrote:
Hello,

Well i'm afraid brother! but you have to use client side script to
fulfil your requirement.

In my opinion there are only two possibilities:

1. Post back & change gridrow color
2. Use a client side script

Unfortunately i could not think of any other way to change gridrow's
color.

Regards,
Mohsin Rizvi

rn**@rediffmail.com wrote:
I am not looking out for a code snippet to change the BackColor of a
row in the DataGrid which is checked; I have already succeeded in doing
that but I did it by setting the AutoPostBack property of the
CheckBoxes in the DataGrid to True. In other words, I am highlighting
the checked row/s using ASP.NET.

What I would like to know is can the same functionality be added to the
CheckBoxes by setting the AutoPostBack property of the CheckBoxes in
the DataGrid to False. I wouldn't like to use JavaScript (or any other
client-side script) to do that & prefer doing this using ASP.NET.

Even I had a look at a number of articles which show how to do this but
all the articles I have come across set AutoPostBack=True for the
CheckBoxes. Did you find any articles which does this by setting
AutoPostBack=False?
Newbie Coder wrote:
Yesterday, I done a Google search for the same thing
>
If you go to http://www.google.com & search for
>
"CheckListBox", "VB.NET" (with quotes & comma) you will find many examples
of what you are looking for
>
>
<rn**@rediffmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
The first column of a DataGrid has a CheckBox for all the rows. I want
that when users check a CheckBox, the BackColor of that entire row in
the DataGrid should change to a different color. To implement this, if
I am not mistaken, I HAVE TO post the Form first i.e. set the
AutoPostBack property of the CheckBox to True. Without posting the
Form, I don't think the BackColor of the checked row can be changed
using ASP.NET, isn't it?

Of course, it can be done using some client side script like JavaScript
but to do it using ASP.NET, I have to post the Form first, isn't it?
hey tell me how can i change the back color of checked checkbox in
grid...i did coding for checked box and it works fine when user checks
the checkbox in header of the grid then all
the checkbox in the grid is checked...if anyone tell me how to set
backcolor of the grid using javascript or any other thing then i'll be
useful...thanks a lot in advance

Dec 4 '06 #5
Nil, this is how I did it (the sub named 'CheckChanged' is the
CheckedChanged event handler of the CheckBox & the AutoPostBack
property of the CheckBox has been set to True; 'chkItem' is the name of
the CheckBox in the DataGrid named 'dg1'):

Sub CheckChanged(ByVal obj As Object, ByVal ea As EventArgs)
Dim chkSelItem As CheckBox
Dim dgItem As DataGridItem

For Each dgItem In dg1.Items
If (dgItem.ItemType = ListItemType.Item Or dgItem.ItemType =
ListItemType.AlternatingItem) Then
chkSelItem = dgItem.FindControl("chkItem")
If (chkSelItem.Checked) Then
dgItem.BackColor = Drawing.Color.LightCyan
End If
End If
Next
End Sub

Hope this helps.....

I was just about to ask you how did you manage to check all the
CheckBoxes in a DataGrid when the CheckBox in the Header is checked but
found that you have already answered that.......

nil wrote:
Mohsin Rizvi wrote:
Hello,

Well i'm afraid brother! but you have to use client side script to
fulfil your requirement.

In my opinion there are only two possibilities:

1. Post back & change gridrow color
2. Use a client side script

Unfortunately i could not think of any other way to change gridrow's
color.

Regards,
Mohsin Rizvi

rn**@rediffmail.com wrote:
I am not looking out for a code snippet to change the BackColor of a
row in the DataGrid which is checked; I have already succeeded in doing
that but I did it by setting the AutoPostBack property of the
CheckBoxes in the DataGrid to True. In other words, I am highlighting
the checked row/s using ASP.NET.
>
What I would like to know is can the same functionality be added to the
CheckBoxes by setting the AutoPostBack property of the CheckBoxes in
the DataGrid to False. I wouldn't like to use JavaScript (or any other
client-side script) to do that & prefer doing this using ASP.NET.
>
Even I had a look at a number of articles which show how to do this but
all the articles I have come across set AutoPostBack=True for the
CheckBoxes. Did you find any articles which does this by setting
AutoPostBack=False?
>
>
Newbie Coder wrote:
Yesterday, I done a Google search for the same thing

If you go to http://www.google.com & search for

"CheckListBox", "VB.NET" (with quotes & comma) you will find many examples
of what you are looking for


<rn**@rediffmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
The first column of a DataGrid has a CheckBox for all the rows. I want
that when users check a CheckBox, the BackColor of that entire row in
the DataGrid should change to a different color. To implement this, if
I am not mistaken, I HAVE TO post the Form first i.e. set the
AutoPostBack property of the CheckBox to True. Without posting the
Form, I don't think the BackColor of the checked row can be changed
using ASP.NET, isn't it?
>
Of course, it can be done using some client side script like JavaScript
but to do it using ASP.NET, I have to post the Form first, isn't it?
>

hey tell me how can i change the back color of checked checkbox in
grid...i did coding for checked box and it works fine when user checks
the checkbox in header of the grid then all
the checkbox in the grid is checked...if anyone tell me how to set
backcolor of the grid using javascript or any other thing then i'll be
useful...thanks a lot in advance
Dec 4 '06 #6
nil

rn**@rediffmail.com wrote:
Nil, this is how I did it (the sub named 'CheckChanged' is the
CheckedChanged event handler of the CheckBox & the AutoPostBack
property of the CheckBox has been set to True; 'chkItem' is the name of
the CheckBox in the DataGrid named 'dg1'):

Sub CheckChanged(ByVal obj As Object, ByVal ea As EventArgs)
Dim chkSelItem As CheckBox
Dim dgItem As DataGridItem

For Each dgItem In dg1.Items
If (dgItem.ItemType = ListItemType.Item Or dgItem.ItemType =
ListItemType.AlternatingItem) Then
chkSelItem = dgItem.FindControl("chkItem")
If (chkSelItem.Checked) Then
dgItem.BackColor = Drawing.Color.LightCyan
End If
End If
Next
End Sub

Hope this helps.....

I was just about to ask you how did you manage to check all the
CheckBoxes in a DataGrid when the CheckBox in the Header is checked but
found that you have already answered that.......

nil wrote:
Mohsin Rizvi wrote:
Hello,
>
Well i'm afraid brother! but you have to use client side script to
fulfil your requirement.
>
In my opinion there are only two possibilities:
>
1. Post back & change gridrow color
2. Use a client side script
>
Unfortunately i could not think of any other way to change gridrow's
color.
>
Regards,
Mohsin Rizvi
>
rn**@rediffmail.com wrote:
I am not looking out for a code snippet to change the BackColor of a
row in the DataGrid which is checked; I have already succeeded in doing
that but I did it by setting the AutoPostBack property of the
CheckBoxes in the DataGrid to True. In other words, I am highlighting
the checked row/s using ASP.NET.

What I would like to know is can the same functionality be added to the
CheckBoxes by setting the AutoPostBack property of the CheckBoxes in
the DataGrid to False. I wouldn't like to use JavaScript (or any other
client-side script) to do that & prefer doing this using ASP.NET.

Even I had a look at a number of articles which show how to do this but
all the articles I have come across set AutoPostBack=True for the
CheckBoxes. Did you find any articles which does this by setting
AutoPostBack=False?


Newbie Coder wrote:
Yesterday, I done a Google search for the same thing
>
If you go to http://www.google.com & search for
>
"CheckListBox", "VB.NET" (with quotes & comma) you will find many examples
of what you are looking for
>
>
<rn**@rediffmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
The first column of a DataGrid has a CheckBox for all the rows. I want
that when users check a CheckBox, the BackColor of that entire row in
the DataGrid should change to a different color. To implement this, if
I am not mistaken, I HAVE TO post the Form first i.e. set the
AutoPostBack property of the CheckBox to True. Without posting the
Form, I don't think the BackColor of the checked row can be changed
using ASP.NET, isn't it?

Of course, it can be done using some client side script like JavaScript
but to do it using ASP.NET, I have to post the Form first, isn't it?
hey tell me how can i change the back color of checked checkbox in
grid...i did coding for checked box and it works fine when user checks
the checkbox in header of the grid then all
the checkbox in the grid is checked...if anyone tell me how to set
backcolor of the grid using javascript or any other thing then i'll be
useful...thanks a lot in advance

ya i used java script for that and it's work fine as i don't want page
to be refressh each time

Dec 4 '06 #7
nil

nil wrote:
rn**@rediffmail.com wrote:
Nil, this is how I did it (the sub named 'CheckChanged' is the
CheckedChanged event handler of the CheckBox & the AutoPostBack
property of the CheckBox has been set to True; 'chkItem' is the name of
the CheckBox in the DataGrid named 'dg1'):

Sub CheckChanged(ByVal obj As Object, ByVal ea As EventArgs)
Dim chkSelItem As CheckBox
Dim dgItem As DataGridItem

For Each dgItem In dg1.Items
If (dgItem.ItemType = ListItemType.Item Or dgItem.ItemType =
ListItemType.AlternatingItem) Then
chkSelItem = dgItem.FindControl("chkItem")
If (chkSelItem.Checked) Then
dgItem.BackColor = Drawing.Color.LightCyan
End If
End If
Next
End Sub

Hope this helps.....

I was just about to ask you how did you manage to check all the
CheckBoxes in a DataGrid when the CheckBox in the Header is checked but
found that you have already answered that.......

nil wrote:
Mohsin Rizvi wrote:
Hello,

Well i'm afraid brother! but you have to use client side script to
fulfil your requirement.

In my opinion there are only two possibilities:

1. Post back & change gridrow color
2. Use a client side script

Unfortunately i could not think of any other way to change gridrow's
color.

Regards,
Mohsin Rizvi

rn**@rediffmail.com wrote:
I am not looking out for a code snippet to change the BackColor of a
row in the DataGrid which is checked; I have already succeeded in doing
that but I did it by setting the AutoPostBack property of the
CheckBoxes in the DataGrid to True. In other words, I am highlighting
the checked row/s using ASP.NET.
>
What I would like to know is can the same functionality be added to the
CheckBoxes by setting the AutoPostBack property of the CheckBoxes in
the DataGrid to False. I wouldn't like to use JavaScript (or any other
client-side script) to do that & prefer doing this using ASP.NET.
>
Even I had a look at a number of articles which show how to do this but
all the articles I have come across set AutoPostBack=True for the
CheckBoxes. Did you find any articles which does this by setting
AutoPostBack=False?
>
>
Newbie Coder wrote:
Yesterday, I done a Google search for the same thing

If you go to http://www.google.com & search for

"CheckListBox", "VB.NET" (with quotes & comma) you will find many examples
of what you are looking for


<rn**@rediffmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
The first column of a DataGrid has a CheckBox for all the rows. I want
that when users check a CheckBox, the BackColor of that entire row in
the DataGrid should change to a different color. To implement this, if
I am not mistaken, I HAVE TO post the Form first i.e. set the
AutoPostBack property of the CheckBox to True. Without posting the
Form, I don't think the BackColor of the checked row can be changed
using ASP.NET, isn't it?
>
Of course, it can be done using some client side script like JavaScript
but to do it using ASP.NET, I have to post the Form first, isn't it?
>
>
hey tell me how can i change the back color of checked checkbox in
grid...i did coding for checked box and it works fine when user checks
the checkbox in header of the grid then all
the checkbox in the grid is checked...if anyone tell me how to set
backcolor of the grid using javascript or any other thing then i'll be
useful...thanks a lot in advance


ya i used java script for that and it's work fine as i don't want page
to be refressh each time


hello i have used java script so tell me how to do that in
javascript?thanks for the previous coding...

Dec 5 '06 #8

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

Similar topics

2
by: Mortar | last post by:
i have a datagrid with a column of html checkboxes which are created dynamically. The id/name of the checkboxes comes from a value in the database. on a postback, i would like to get all the...
1
by: kannadasan | last post by:
Hi all I am using Datagrid where i place checkboxes in one column with some other columns.The purpose is, if i select the checkboxes and clicks the submit buton Email has to go to the selected...
7
by: DJ Dev | last post by:
Hi All, I have a complex problem. I have dropdownlists (usually 3-5) and the user selects some value from these and for each value selected, datagrids are shown to the user. I am creating the...
2
by: john | last post by:
I posted this question to comp.lang.javascript but didn't get a response, so I'll try here. I am using ASP.NET and I have a datagrid. One of the columns in my grid is all checkboxes. When the...
2
by: Mortar | last post by:
i have a datagrid with 2 columns. the 1st column contains an id which will be used by the database for the selected checkbox records. the 2nd column is a template column containing a server...
4
by: Jim Bancroft | last post by:
Hi everyone, I'm using a DataGrid with TemplateColumns. My DataGrid is located in a cell of an asp:Table. I did this so it's positioned correctly onscreen. One of the DataGrid's...
3
by: GatorBait | last post by:
Hi all, I'm using a datagrid for the first time and I am running into some problems that I hope someone can help me with. I have a datagrid with 18 rows and 5 columns....column 1 is just text...
6
by: arun.hallan | last post by:
Hi, I have a datagrid whose datasource is a datatable which is saved to viewstate on page_load. I also have a cached string which handles what is shown on the rowfilter of the dataview of...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
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: 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.