Hi Steve,
I am glad to hear it. Thanks for using Microsoft Newsgroups.
Best regards,
Lewis
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "IntraRELY" <
[email protected]>
| References: <
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<#
[email protected]>
<
[email protected]>
| Subject: Re: CheckBox Template Column
| Date: Fri, 29 Aug 2003 10:41:19 -0700
| Lines: 296
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
| Path:
cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!tk2msftngp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:6411
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
|
| Lewis,
|
| Wanted to thank you for you support...it was superb.
|
| Have a wonderful Labor Day weekend.
|
| Steve Wofford
|
www.IntraRELY.com
|
| | > Hi Steve,
| >
| > Thank you for your reply.
| >
| > Do you mean not to change the red color of the checked GridItem when the
| > mouse is over it? You may check the prior color of the GridItem before
| > changing its color.
| >
| > The following is a snippet in datagrid.ItemDataBound. You may modify it
to
| > meet your requirements.
| >
| > if( e.Item.ItemType == ListItemType.Item || e.Item.ItemType
| > ==ListItemType.AlternatingItem )
| > {
| >
| >
|
e.Item.Attributes.Add("onmouseover","if(this.style.backgroundColor!='red')th
| > is.style.backgroundColor='silver'");
| > e.Item.Attributes.Add("onmouseout",
| >
|
"if(this.style.backgroundColor!='red')this.style.backgroundColor='white';");
| > }
| >
| > Hope this helps.
| >
| > Best regards,
| > Lewis
| >
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| >
| > --------------------
| > | From: "IntraRELY" <
[email protected]>
| > | References: <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > | Subject: Re: CheckBox Template Column
| > | Date: Wed, 27 Aug 2003 10:37:11 -0700
| > | Lines: 206
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <#
[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.datagridcontrol:6384
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > |
| > | Lewis, Thank you so much for this information, one of the best
responses
| > | ever. Truely appreciated.
| > |
| > | The code below works great, but since I am using highlights for
| > onmouseover
| > | it is changing the checked rows background color. Remember I am
| > highlighting
| > | 2 differant events.
| > |
| > | 1. simple onmouseover
| > | 2. check rows
| > |
| > | How do I tell it to ignore rows that have a checked box? The code is
in
| > the
| > | original dgDepositories_ItemDataBound sub
| > |
| > | Thanks again,
| > |
| > | Steve Wofford
| > |
www.IntraRELY.com
| > |
| > | | > | > Hi Steve,
| > | >
| > | > There is two ways to resolve this issue. One is on the server side
| code
| > | and
| > | > another is on the client side.
| > | >
| > | > 1. Server side: using "(DataGridItem)chkTemp.Parent .Parent" to get
| the
| > | > reference of the DataGridItem.
| > | >
| > | > public void dgDepositories_checkedchanged(object sender,
| > System.EventArgs
| > | e)
| > | > {
| > | > CheckBox chkTemp= (CheckBox)sender;
| > | > if(chkTemp.Checked)
| > | > {
| > | > DataGridItem dgi=(DataGridItem)chkTemp.Parent.Parent;
| > | > dgi.BackColor =Color.Red ;
| > | > }
| > | > else
| > | > {
| > | > DataGridItem dgi=(DataGridItem)chkTemp.Parent.Parent;
| > | > dgi.BackColor =Color.White;
| > | > }
| > | > }
| > | >
| > | >
| > | > 2. Client side: using
| > | > "this.parentElement.parentElement.style.backgroundColor" to
highlight
| > the
| > | > whole datagrid row. Here is a code snippet, you may modify it to
meet
| > your
| > | > requirements.
| > | >
| > | > . .
| > | > <ItemTemplate>
| > | > <asp:CheckBox id="CheckBox1" runat="server"
| > | >
| > |
| >
|
onclick="if(this.parentElement.parentElement.style.backgroundColor!='red')th
| > | > is.parentElement.parentElement.style.backgroundColor='red';else
| > | >
| > |
| >
|
this.parentElement.parentElement.style.backgroundColor='white';"></asp:Check
| > | > Box>
| > | > . . .
| > | > </ItemTemplate>
| > | > . .
| > | >
| > | > Does this answer your question? Please let me know if you need more
| > | > information
| > | >
| > | > Best regards,
| > | > Lewis
| > | >
| > | > This posting is provided "AS IS" with no warranties, and confers no
| > | rights.
| > | >
| > | > --------------------
| > | > | Newsgroups:
microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > | From: (e-mail address removed) (Lewis Wang [MSFT])
| > | > | Organization: Microsoft
| > | > | Date: Wed, 27 Aug 2003 05:13:58 GMT
| > | > | Subject: Re: CheckBox Template Column
| > | > | X-Tomcat-NG:
| microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > | MIME-Version: 1.0
| > | > | Content-Type: text/plain
| > | > | Content-Transfer-Encoding: 7bit
| > | > |
| > | > | Hi Steve,
| > | > |
| > | > | Thanks for your posting. I am checking this issue, and will get
back
| > to
| > | > you
| > | > | with my findings.
| > | > |
| > | > | Best regards,
| > | > | Lewis
| > | > |
| > | > | This posting is provided "AS IS" with no warranties, and confers
no
| > | > rights.
| > | > | --------------------
| > | > | | From: "IntraRELY" <
[email protected]>
| > | > | | References: <
[email protected]>
| > | > | | Subject: Re: CheckBox Template Column
| > | > | | Date: Tue, 26 Aug 2003 16:53:45 -0700
| > | > | | Lines: 74
| > | > | | X-Priority: 3
| > | > | | X-MSMail-Priority: Normal
| > | > | | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | > | | Message-ID: <
[email protected]>
| > | > | | Newsgroups:
| microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > | | NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
| > | > | | Path:
| cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| > | > | | Xref: cpmsftngxa06.phx.gbl
| > | > | microsoft.public.dotnet.framework.aspnet.datagridcontrol:6360
| > | > | | X-Tomcat-NG:
| > microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > | |
| > | > | | I added my code but if you look at the last sub, it creates the
| red
| > | > | | background but I need to make the whole background for the row
| red.
| > | You
| > | > | will
| > | > | | see the first sub does this with mouse overs, but I need the
| checked
| > | > rows
| > | > | to
| > | > | | remain highlighted, but cannot get it to work.
| > | > | |
| > | > | | TIA,
| > | > | |
| > | > | | Steve
| > | > | |
| > | > | | =============ASP
| > | > | | <asp:datagrid id="dgDepositories" style="Z-INDEX: 103; LEFT:
32px;
| > | > | POSITION:
| > | > | | absolute; TOP: 40px"
| > | > | | runat="server"
| > | > | | OnPageIndexChanged="dgDepositories_PageIndexChanged"
| > | > | | DataKeyField="depositoryId"
| > | > | | AutoGenerateColumns="False"
| > | > | | PageSize="3"
| > | > | | AllowPaging="True"
| > | > | | AllowCustomPaging="True"
| > | > | | PagerStyle-Mode="NumericPages"
| > | > | | OnItemDataBound="dgDepositories_ItemDataBound">
| > | > | | <Columns>
| > | > | | <asp:TemplateColumn HeaderText="Delete">
| > | > | | <ItemTemplate>
| > | > | | <asp:CheckBox id="cbDelete"
| > | > | | runat="server"
| > | > | | OnCheckedChanged="dgDepositories_checkedchanged"
| > | > | | AutoPostBack="True">
| > | > | | </asp:CheckBox>
| > | > | | </ItemTemplate>
| > | > | | </asp:TemplateColumn>
| > | > | | </Columns>
| > | > | | </asp:datagrid>
| > | > | | =======Code Behind
| > | > | | Public Sub dgDepositories_ItemDataBound(ByVal sender As Object,
| > ByVal
| > | e
| > | > _
| > | > | | As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
| > | > | | dgDepositories.ItemDataBound
| > | > | | ' Changes the background on mouse overs
| > | > | | If e.Item.ItemType = ListItemType.Item Or _
| > | > | | e.Item.ItemType = ListItemType.AlternatingItem Then
| > | > | | e.Item.Attributes.Add("onmouseover",
| > | > | "this.style.backgroundColor='Silver'")
| > | > | | e.Item.Attributes.Add("onmouseout",
| > | > "this.style.backgroundColor='white'")
| > | > | | End If
| > | > | | End Sub
| > | > | |
| > | > | | -----
| > | > | | Public Sub dgDepositories_checkedchanged(ByVal sender As Object,
| > ByVal
| > | > e
| > | > | As
| > | > | | System.EventArgs) _
| > | > | | Dim chkTemp As System.Web.UI.WebControls.CheckBox
| > | > | | ' Makes the background red for just the checkbox cell.
| > | > | | chkTemp = sender
| > | > | | If chkTemp.Checked = True Then
| > | > | | lblMessage.Text = (chkTemp.UniqueID & "Is now checked")
| > | > | | chkTemp.Attributes.Add("onmouseover",
| > | > "this.style.backgroundColor='red'")
| > | > | | Else
| > | > | | lblMessage.Text = (chkTemp.UniqueID & "Is now un-checked")
| > | > | | chkTemp.Attributes.Add("onmouseover",
| > | > | "this.style.backgroundColor='white'")
| > | > | | End If
| > | > | | End Sub
| > | > | |
| > | > | |
| > | > | | | > | > | | > I need to highlight a datagrid row if the check box is
selected
| > for
| > | > that
| > | > | | > row. I am really not clear how to reference it.
| > | > | | >
| > | > | | > TIA,
| > | > | | >
| > | > | | > Steve Wofford
| > | > | | >
www.IntraRELY.com
| > | > | | >
| > | > | | >
| > | > | |
| > | > | |
| > | > | |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|