CheckBox Template Column

Discussion in 'ASP .Net Datagrid Control' started by IntraRELY, Aug 26, 2003.

  1. IntraRELY

    IntraRELY Guest

    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
    IntraRELY, Aug 26, 2003
    #1
    1. Advertising

  2. IntraRELY

    IntraRELY Guest

    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


    "IntraRELY" <> wrote in message
    news:O$...
    > 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
    >
    >
    IntraRELY, Aug 27, 2003
    #2
    1. Advertising

  3. 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" <>
    | References: <O$>
    | 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$>
    | 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
    |
    |
    | "IntraRELY" <> wrote in message
    | news:O$...
    | > 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
    | >
    | >
    |
    |
    |
    Lewis Wang [MSFT], Aug 27, 2003
    #3
  4. 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: (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" <>
    | | References: <O$>
    | | 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$>
    | | 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
    | |
    | |
    | | "IntraRELY" <> wrote in message
    | | news:O$...
    | | > 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
    | | >
    | | >
    | |
    | |
    | |
    |
    Lewis Wang [MSFT], Aug 27, 2003
    #4
  5. IntraRELY

    Teemu Keiski Guest

    Andy Smith's free RowSelectorColumn can be useful in these scenarios as
    well.
    http://www.metabuilders.com/Tools/RowSelectorColumn.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]" <> kirjoitti viestissä
    news:eek:...
    > 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: (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" <>
    > | | References: <O$>
    > | | 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$>
    > | | 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
    > | |
    > | |
    > | | "IntraRELY" <> wrote in message
    > | | news:O$...
    > | | > 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
    > | | >
    > | | >
    > | |
    > | |
    > | |
    > |
    >
    Teemu Keiski, Aug 27, 2003
    #5
  6. IntraRELY

    IntraRELY Guest

    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]" <> wrote in message
    news:eek:...
    > 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: (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" <>
    > | | References: <O$>
    > | | 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$>
    > | | 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
    > | |
    > | |
    > | | "IntraRELY" <> wrote in message
    > | | news:O$...
    > | | > 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
    > | | >
    > | | >
    > | |
    > | |
    > | |
    > |
    >
    IntraRELY, Aug 27, 2003
    #6
  7. 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" <>
    | References: <O$>
    <eeEo$>
    <>
    <>
    | 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: <#>
    | 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
    |
    | "Lewis Wang [MSFT]" <> wrote in message
    | news:eek:...
    | > 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: (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" <>
    | > | | References: <O$>
    | > | | 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$>
    | > | | 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
    | > | |
    | > | |
    | > | | "IntraRELY" <> wrote in message
    | > | | news:O$...
    | > | | > 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
    | > | | >
    | > | | >
    | > | |
    | > | |
    | > | |
    | > |
    | >
    |
    |
    |
    Lewis Wang [MSFT], Aug 28, 2003
    #7
  8. IntraRELY

    IntraRELY Guest

    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]" <> wrote in message
    news:$...
    > 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" <>
    > | References: <O$>
    > <eeEo$>
    > <>
    > <>
    > | 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: <#>
    > | 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
    > |
    > | "Lewis Wang [MSFT]" <> wrote in message
    > | news:eek:...
    > | > 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: (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" <>
    > | > | | References: <O$>
    > | > | | 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$>
    > | > | | 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
    > | > | |
    > | > | |
    > | > | | "IntraRELY" <> wrote in message
    > | > | | news:O$...
    > | > | | > 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
    > | > | | >
    > | > | | >
    > | > | |
    > | > | |
    > | > | |
    > | > |
    > | >
    > |
    > |
    > |
    >
    IntraRELY, Aug 29, 2003
    #8
  9. 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" <>
    | References: <O$>
    <eeEo$>
    <>
    <>
    <#>
    <$>
    | 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: <>
    | 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
    |
    | "Lewis Wang [MSFT]" <> wrote in message
    | news:$...
    | > 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" <>
    | > | References: <O$>
    | > <eeEo$>
    | > <>
    | > <>
    | > | 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: <#>
    | > | 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
    | > |
    | > | "Lewis Wang [MSFT]" <> wrote in message
    | > | news:eek:...
    | > | > 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: (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" <>
    | > | > | | References: <O$>
    | > | > | | 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$>
    | > | > | | 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
    | > | > | |
    | > | > | |
    | > | > | | "IntraRELY" <> wrote in message
    | > | > | | news:O$...
    | > | > | | > 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
    | > | > | | >
    | > | > | | >
    | > | > | |
    | > | > | |
    | > | > | |
    | > | > |
    | > | >
    | > |
    | > |
    | > |
    | >
    |
    |
    |
    Lewis Wang [MSFT], Sep 1, 2003
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric Caron

    Checkbox in a template column

    Eric Caron, Sep 30, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    361
    =?Utf-8?B?c3Jpbmk=?=
    Oct 1, 2004
  2. =?Utf-8?B?d3djb29w?=

    Checkbox Template Column will not display

    =?Utf-8?B?d3djb29w?=, Mar 29, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    406
    =?Utf-8?B?d3djb29w?=
    Mar 29, 2005
  3. Ryan Lafferty

    DataGrid control with checkbox template column

    Ryan Lafferty, Aug 8, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    3,276
    Ryan Lafferty
    Aug 8, 2005
  4. Javier
    Replies:
    2
    Views:
    4,094
    Javier
    Dec 12, 2005
  5. Gregory Rampton

    Convert an MS Access Yes/No column to a checkbox column in C# datagrid

    Gregory Rampton, Aug 6, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    187
    Gregory Rampton
    Aug 6, 2003
Loading...

Share This Page