By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,273 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,273 IT Pros & Developers. It's quick & easy.

CheckBoxes in DataGrid

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.