Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > CheckBox Template Column

Reply
Thread Tools

CheckBox Template Column

 
 
IntraRELY
Guest
Posts: n/a
 
      08-26-2003
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


 
Reply With Quote
 
 
 
 
IntraRELY
Guest
Posts: n/a
 
      08-26-2003
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_PageIndexChange d"
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


"IntraRELY" <(E-Mail Removed)> wrote in message
news:O$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Lewis Wang [MSFT]
Guest
Posts: n/a
 
      08-27-2003
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" <(E-Mail Removed)>
| References: <O$(E-Mail Removed)>
| 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: <eeEo$(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridc ontrol:6360
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
|
| 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_PageIndexChange d"
| 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
|
|
| "IntraRELY" <(E-Mail Removed)> wrote in message
| news:O$(E-Mail Removed)...
| > 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
| >
| >
|
|
|

 
Reply With Quote
 
Lewis Wang [MSFT]
Guest
Posts: n/a
 
      08-27-2003
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.background Color" 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.backgroundCol or='red';else
this.parentElement.parentElement.style.backgroundC olor='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.datagridc ontrol
| From: http://www.velocityreviews.com/forums/(E-Mail 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.datagridc ontrol
| 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" <(E-Mail Removed)>
| | References: <O$(E-Mail Removed)>
| | 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: <eeEo$(E-Mail Removed)>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| | NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
| | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
| | Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.aspnet.datagridc ontrol:6360
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| |
| | 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_PageIndexChange d"
| | 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
| |
| |
| | "IntraRELY" <(E-Mail Removed)> wrote in message
| | news:O$(E-Mail Removed)...
| | > 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
| | >
| | >
| |
| |
| |
|

 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      08-27-2003
Andy Smith's free RowSelectorColumn can be useful in these scenarios as
well.
http://www.metabuilders.com/Tools/Ro...torColumn.aspx

--
Teemu Keiski
MCP,Designer/Developer
Mansoft tietotekniikka Oy
http://www.mansoft.fi

AspInsiders Member, www.aspinsiders.com
ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com

"Lewis Wang [MSFT]" <(E-Mail Removed)> kirjoitti viestissä
news(E-Mail Removed)...
> 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.background Color" 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.backgroundCol or='red';else
>

this.parentElement.parentElement.style.backgroundC olor='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.datagridc ontrol
> | From: (E-Mail 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.datagridc ontrol
> | 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" <(E-Mail Removed)>
> | | References: <O$(E-Mail Removed)>
> | | 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: <eeEo$(E-Mail Removed)>
> | | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
> | | NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
> | | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
> | | Xref: cpmsftngxa06.phx.gbl
> | microsoft.public.dotnet.framework.aspnet.datagridc ontrol:6360
> | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
> | |
> | | 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_PageIndexChange d"
> | | 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
> | |
> | |
> | | "IntraRELY" <(E-Mail Removed)> wrote in message
> | | news:O$(E-Mail Removed)...
> | | > 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
> | | >
> | | >
> | |
> | |
> | |
> |
>



 
Reply With Quote
 
IntraRELY
Guest
Posts: n/a
 
      08-27-2003
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

"Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> 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.background Color" 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.backgroundCol or='red';else
>

this.parentElement.parentElement.style.backgroundC olor='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.datagridc ontrol
> | From: (E-Mail 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.datagridc ontrol
> | 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" <(E-Mail Removed)>
> | | References: <O$(E-Mail Removed)>
> | | 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: <eeEo$(E-Mail Removed)>
> | | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
> | | NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
> | | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
> | | Xref: cpmsftngxa06.phx.gbl
> | microsoft.public.dotnet.framework.aspnet.datagridc ontrol:6360
> | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
> | |
> | | 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_PageIndexChange d"
> | | 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
> | |
> | |
> | | "IntraRELY" <(E-Mail Removed)> wrote in message
> | | news:O$(E-Mail Removed)...
> | | > 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
> | | >
> | | >
> | |
> | |
> | |
> |
>



 
Reply With Quote
 
Lewis Wang [MSFT]
Guest
Posts: n/a
 
      08-28-2003
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.b ackgroundColor='white';");
}

Hope this helps.

Best regards,
Lewis

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: "IntraRELY" <(E-Mail Removed)>
| References: <O$(E-Mail Removed)>
<eeEo$(E-Mail Removed)>
<(E-Mail Removed)>
<(E-Mail Removed)>
| 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: <#(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridc ontrol:6384
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
|
| 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
|
| "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
| news(E-Mail Removed)...
| > 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.background Color" 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.backgroundCol or='red';else
| >
|
this.parentElement.parentElement.style.backgroundC olor='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.datagridc ontrol
| > | From: (E-Mail 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.datagridc ontrol
| > | 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" <(E-Mail Removed)>
| > | | References: <O$(E-Mail Removed)>
| > | | 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: <eeEo$(E-Mail Removed)>
| > | | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| > | | NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
| > | | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
| > | | Xref: cpmsftngxa06.phx.gbl
| > | microsoft.public.dotnet.framework.aspnet.datagridc ontrol:6360
| > | | X-Tomcat-NG:
microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| > | |
| > | | 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_PageIndexChange d"
| > | | 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
| > | |
| > | |
| > | | "IntraRELY" <(E-Mail Removed)> wrote in message
| > | | news:O$(E-Mail Removed)...
| > | | > 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
| > | | >
| > | | >
| > | |
| > | |
| > | |
| > |
| >
|
|
|

 
Reply With Quote
 
IntraRELY
Guest
Posts: n/a
 
      08-29-2003
Lewis,

Wanted to thank you for you support...it was superb.

Have a wonderful Labor Day weekend.

Steve Wofford
www.IntraRELY.com

"Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
news:$(E-Mail Removed)...
> 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.b ackgroundColor='white';");
> }
>
> Hope this helps.
>
> Best regards,
> Lewis
>
> This posting is provided "AS IS" with no warranties, and confers no

rights.
>
> --------------------
> | From: "IntraRELY" <(E-Mail Removed)>
> | References: <O$(E-Mail Removed)>
> <eeEo$(E-Mail Removed)>
> <(E-Mail Removed)>
> <(E-Mail Removed)>
> | 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: <#(E-Mail Removed)>
> | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
> | NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
> | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
> | Xref: cpmsftngxa06.phx.gbl
> microsoft.public.dotnet.framework.aspnet.datagridc ontrol:6384
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
> |
> | 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
> |
> | "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
> | news(E-Mail Removed)...
> | > 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.background Color" 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.backgroundCol or='red';else
> | >
> |
>

this.parentElement.parentElement.style.backgroundC olor='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.datagridc ontrol
> | > | From: (E-Mail 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.datagridc ontrol
> | > | 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" <(E-Mail Removed)>
> | > | | References: <O$(E-Mail Removed)>
> | > | | 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: <eeEo$(E-Mail Removed)>
> | > | | Newsgroups:

microsoft.public.dotnet.framework.aspnet.datagridc ontrol
> | > | | NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
> | > | | Path:

cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
> | > | | Xref: cpmsftngxa06.phx.gbl
> | > | microsoft.public.dotnet.framework.aspnet.datagridc ontrol:6360
> | > | | X-Tomcat-NG:
> microsoft.public.dotnet.framework.aspnet.datagridc ontrol
> | > | |
> | > | | 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_PageIndexChange d"
> | > | | 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
> | > | |
> | > | |
> | > | | "IntraRELY" <(E-Mail Removed)> wrote in message
> | > | | news:O$(E-Mail Removed)...
> | > | | > 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
> | > | | >
> | > | | >
> | > | |
> | > | |
> | > | |
> | > |
> | >
> |
> |
> |
>



 
Reply With Quote
 
Lewis Wang [MSFT]
Guest
Posts: n/a
 
      09-01-2003
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" <(E-Mail Removed)>
| References: <O$(E-Mail Removed)>
<eeEo$(E-Mail Removed)>
<(E-Mail Removed)>
<(E-Mail Removed)>
<#(E-Mail Removed)>
<$(E-Mail Removed)>
| 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: <(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
| Path:
cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!tk2msftngp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridc ontrol:6411
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
|
| Lewis,
|
| Wanted to thank you for you support...it was superb.
|
| Have a wonderful Labor Day weekend.
|
| Steve Wofford
| www.IntraRELY.com
|
| "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
| news:$(E-Mail Removed)...
| > 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.b ackgroundColor='white';");
| > }
| >
| > Hope this helps.
| >
| > Best regards,
| > Lewis
| >
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| >
| > --------------------
| > | From: "IntraRELY" <(E-Mail Removed)>
| > | References: <O$(E-Mail Removed)>
| > <eeEo$(E-Mail Removed)>
| > <(E-Mail Removed)>
| > <(E-Mail Removed)>
| > | 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: <#(E-Mail Removed)>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| > | NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:6384
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| > |
| > | 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
| > |
| > | "Lewis Wang [MSFT]" <(E-Mail Removed)> wrote in message
| > | news(E-Mail Removed)...
| > | > 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.background Color" 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.backgroundCol or='red';else
| > | >
| > |
| >
|
this.parentElement.parentElement.style.backgroundC olor='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.datagridc ontrol
| > | > | From: (E-Mail 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.datagridc ontrol
| > | > | 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" <(E-Mail Removed)>
| > | > | | References: <O$(E-Mail Removed)>
| > | > | | 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: <eeEo$(E-Mail Removed)>
| > | > | | Newsgroups:
| microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| > | > | | NNTP-Posting-Host: wsip-68-106-74-63.oc.oc.cox.net 68.106.74.63
| > | > | | Path:
| cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
| > | > | | Xref: cpmsftngxa06.phx.gbl
| > | > | microsoft.public.dotnet.framework.aspnet.datagridc ontrol:6360
| > | > | | X-Tomcat-NG:
| > microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| > | > | |
| > | > | | 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_PageIndexChange d"
| > | > | | 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
| > | > | |
| > | > | |
| > | > | | "IntraRELY" <(E-Mail Removed)> wrote in message
| > | > | | news:O$(E-Mail Removed)...
| > | > | | > 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
| > | > | | >
| > | > | | >
| > | > | |
| > | > | |
| > | > | |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CheckBox unchecked status detection in DataGrid Template Column Javier ASP .Net 2 12-12-2005 05:16 PM
DataGrid control with checkbox template column Ryan Lafferty ASP .Net 2 08-08-2005 05:16 PM
Checkbox Template Column will not display =?Utf-8?B?d3djb29w?= ASP .Net 0 03-29-2005 08:27 PM
Checkbox in a template column Eric Caron ASP .Net 1 10-01-2004 06:27 AM
Convert an MS Access Yes/No column to a checkbox column in C# datagrid Gregory Rampton ASP .Net Datagrid Control 0 08-06-2003 04:09 PM



Advertisments