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

How change gridview row backcolor by check a checkbox in C#

Hi
I send the detail code below.I have the problem when i click the checkbox there is no effect on the gridview's row.Again after a few seconds the checkbox is automatically unchecked.There is no error shows.Please help me.
=======================================
protected void rowedit(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox status = ((CheckBox)(row.Cells[0].Controls[1]));

if (status.Checked == true)
{

row.BackColor = System.Drawing.Color.Red;

}
else if (status.Checked == false)
{
row.BackColor = System.Drawing.Color.White;
}

}
}
------------
Source code
==================
<div>
<asp:GridView ID="GridView1" runat="server" Style="z-index: 100; left: 24px; position: absolute;
top: 88px" Width="232px" >
<Columns>

<asp:TemplateField>


<ItemTemplate>

<asp:CheckBox ID="chk1" runat="server" AutoPostBack="true" OnCheckedChanged="rowedit" />

</ItemTemplate>

</asp:TemplateField>
</Columns>
</asp:GridView>

</div>
Feb 3 '08 #1
1 9074
radcaesar
759 Expert 512MB
Here is the solution

http://www.netomatix.com/development/gridviewrowselectedstyle.aspx
Feb 4 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Hongbo | last post by:
Hi, I have a GridView like this one: == <asp:gridview runat="server" id="gvCategory" allowpaging="true" allowsorting="true" alternatingrowstyle-backcolor="#B9DFC7" autogeneratecolumns="false" ...
2
by: dba123 | last post by:
How do I take my GridView and create a function that will update -all- checkbox values for the submit button's OnClick event? I have posted both my SQLDataSource and my GridView below: ...
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
3
by: r.hein | last post by:
I've got a middle tier data object that I'm binding a gridview to, and I'm having some problems with the check box, and having it enabled. Let'd start with the middle tier object (and the...
3
by: windy | last post by:
I would like to change the backcolor inside the checkbox when the component is on focus, not the color of the text. Thanks a lot.
5
by: LamSoft | last post by:
If there is a table(2x2) generated from the gridview as below checkbox-1 mytest-1 mytest-2 checkbox-1 mytest-3 mytest-3 I know how to check that two checkbox are checked or...
0
by: ganesh22 | last post by:
Hi... Iam using GridView in asp.net(2.0) .My requirement is user can add,update,delete in gridview I written the code for add & update but can u help adding rows in grid view My code: ...
1
by: =?Utf-8?B?Um9iYnlE?= | last post by:
I'm having trouble picking up the checked state of checkboxes in my GridView. I'm working in VS2008. I added a TemplateField via smartTag "Edit Columns". My GridView markup is: <asp:GridView...
21
tsubasa
by: tsubasa | last post by:
I am working on a wish list where users add products to their list for future purhcases. I am using a GridView to display the records by users after they have login to the shopping cart. How can I...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.