Same DataGrid Issue

Discussion in 'ASP .Net' started by Arvind P Rangan, Mar 1, 2004.

  1. Hi all,
    Case:
    DataGrid is having alternative colors.
    on Edit Item Select can i change the background color of the edit item
    template to the same color it had during the alternative item?

    If so just help me out.
    Thanks
    aRvind.
    Arvind P Rangan, Mar 1, 2004
    #1
    1. Advertising

  2. Hi, Arvind P Rangan,

    Yes, you can change the background color - just test in the EditCommand
    handler if the new EditItemIndex is odd or even. Then set the EditItemStyle
    properties to the corresponding ones in the ItemStyle or to those in the
    AlternatingItemStyle respectively, i.e.:

    [C#]
    void MyDataGrid_Edit(Object sender, DataGridCommandEventArgs e)
    {
    MyDataGrid.EditItemStyle.BackColor =
    (((e.Item.ItemIndex % 2) == 0) ?
    MyDataGrid.ItemStyle.BackColor :
    MyDataGrid.AlternatingItemStyle.BackColor)
    //....
    }

    [VB.NET]
    Sub MyDataGrid_Edit(s As Object, e As DataGridCommandEventArgs)
    MyDataGrid.EditItemStyle.BackColor = IIf( _
    (e.Item.ItemIndex Mod 2) = 0, _
    MyDataGrid.ItemStyle.BackColor, _
    MyDataGrid.AlternatingItemStyle.BackColor)
    '....
    End Sub

    Hope this helps
    Martin
    "Arvind P Rangan" <> wrote in message
    news:#3ejA#4$...
    > Hi all,
    > Case:
    > DataGrid is having alternative colors.
    > on Edit Item Select can i change the background color of the edit item
    > template to the same color it had during the alternative item?
    >
    > If so just help me out.
    > Thanks
    > aRvind.
    >
    >
    Martin Dechev, Mar 1, 2004
    #2
    1. Advertising

  3. Thanks MArtin,
    Actually DAtaGrid handles those things by itself it will take the back color
    of the respective item type.
    Arvind
    "Martin Dechev" <> wrote in message
    news:uSJy0P5$...
    > Hi, Arvind P Rangan,
    >
    > Yes, you can change the background color - just test in the EditCommand
    > handler if the new EditItemIndex is odd or even. Then set the

    EditItemStyle
    > properties to the corresponding ones in the ItemStyle or to those in the
    > AlternatingItemStyle respectively, i.e.:
    >
    > [C#]
    > void MyDataGrid_Edit(Object sender, DataGridCommandEventArgs e)
    > {
    > MyDataGrid.EditItemStyle.BackColor =
    > (((e.Item.ItemIndex % 2) == 0) ?
    > MyDataGrid.ItemStyle.BackColor :
    > MyDataGrid.AlternatingItemStyle.BackColor)
    > //....
    > }
    >
    > [VB.NET]
    > Sub MyDataGrid_Edit(s As Object, e As DataGridCommandEventArgs)
    > MyDataGrid.EditItemStyle.BackColor = IIf( _
    > (e.Item.ItemIndex Mod 2) = 0, _
    > MyDataGrid.ItemStyle.BackColor, _
    > MyDataGrid.AlternatingItemStyle.BackColor)
    > '....
    > End Sub
    >
    > Hope this helps
    > Martin
    > "Arvind P Rangan" <> wrote in message
    > news:#3ejA#4$...
    > > Hi all,
    > > Case:
    > > DataGrid is having alternative colors.
    > > on Edit Item Select can i change the background color of the edit item
    > > template to the same color it had during the alternative item?
    > >
    > > If so just help me out.
    > > Thanks
    > > aRvind.
    > >
    > >

    >
    >
    Arvind P Rangan, Mar 1, 2004
    #3
    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. David Hubbard
    Replies:
    2
    Views:
    827
    David Hubbard
    Jan 12, 2006
  2. Shawn
    Replies:
    2
    Views:
    373
    =?Utf-8?B?RWx0b24gVw==?=
    Feb 19, 2006
  3. =?Utf-8?B?UHVuaXNoZXI=?=

    Need same viewstate for same page across multiple servers

    =?Utf-8?B?UHVuaXNoZXI=?=, Mar 23, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    412
    John Timney \( MVP \)
    Mar 23, 2006
  4. bluebaron
    Replies:
    3
    Views:
    741
    Jonathan N. Little
    Nov 4, 2009
  5. Paul D. Fox

    DataGrid & Form on Same Page Post Issue

    Paul D. Fox, Mar 4, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    136
    Elton Wang
    Mar 5, 2005
Loading...

Share This Page