How to highlight an entire datagrid column?

Discussion in 'ASP .Net Datagrid Control' started by wireless, Aug 30, 2003.

  1. wireless

    wireless Guest

    Selecting a row is easy enough using the MS example:

    private void DataGrid1_ItemDataBound(object sender,
    System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    ListItemType itemType = e.Item.ItemType;
    if ((itemType == ListItemType.Pager) ||
    (itemType == ListItemType.Header) ||
    (itemType == ListItemType.Footer))
    {
    return;
    }
    LinkButton button = (LinkButton)e.Item.Cells[0].Controls[0];
    e.Item.Attributes["onclick"] =
    Page.GetPostBackClientHyperlink(button, "");
    }

    But, how is an entire column selected?

    -David
     
    wireless, Aug 30, 2003
    #1
    1. Advertising

  2. wireless

    Saravana Guest

    Check out this article,
    http://www.microsoft.com/india/msdn/articles/58.aspx

    Basically you need to set the SelectedItemStyle-BackColor
    to highlight the selected row.

    --
    Saravana
    Microsoft India Community Star,MC**
    www.extremeexperts.com



    "wireless" <> wrote in message
    news:...
    > Selecting a row is easy enough using the MS example:
    >
    > private void DataGrid1_ItemDataBound(object sender,
    > System.Web.UI.WebControls.DataGridItemEventArgs e)
    > {
    > ListItemType itemType = e.Item.ItemType;
    > if ((itemType == ListItemType.Pager) ||
    > (itemType == ListItemType.Header) ||
    > (itemType == ListItemType.Footer))
    > {
    > return;
    > }
    > LinkButton button = (LinkButton)e.Item.Cells[0].Controls[0];
    > e.Item.Attributes["onclick"] =
    > Page.GetPostBackClientHyperlink(button, "");
    > }
    >
    > But, how is an entire column selected?
    >
    > -David
     
    Saravana, Aug 31, 2003
    #2
    1. Advertising

  3. wireless

    wireless Guest

    This article tells how to select a row but how is a entire column selected?

    This is different from adding a select or link column to select a row.

    -David

    "Saravana" <> wrote in message news:<>...
    > Check out this article,
    > http://www.microsoft.com/india/msdn/articles/58.aspx
    >
    > Basically you need to set the SelectedItemStyle-BackColor
    > to highlight the selected row.
    >
    > --
    > Saravana
    > Microsoft India Community Star,MC**
    > www.extremeexperts.com
    >
    >
    >
    > "wireless" <> wrote in message
    > news:...
    > > Selecting a row is easy enough using the MS example:
    > >
    > > private void DataGrid1_ItemDataBound(object sender,
    > > System.Web.UI.WebControls.DataGridItemEventArgs e)
    > > {
    > > ListItemType itemType = e.Item.ItemType;
    > > if ((itemType == ListItemType.Pager) ||
    > > (itemType == ListItemType.Header) ||
    > > (itemType == ListItemType.Footer))
    > > {
    > > return;
    > > }
    > > LinkButton button = (LinkButton)e.Item.Cells[0].Controls[0];
    > > e.Item.Attributes["onclick"] =
    > > Page.GetPostBackClientHyperlink(button, "");
    > > }
    > >
    > > But, how is an entire column selected?
    > >
    > > -David
     
    wireless, Sep 2, 2003
    #3
  4. wireless

    Prasad Guest

    Hi

    1. If you want to select the Column by clicking on the Column Header
    what you can do is Set AllowSorting to True and based on the SortExpression
    value you can determine which column select.

    2. Can you be more specific abt how you want to select a Column


    Prasad
    "wireless" <> wrote in message
    news:...
    > Selecting a row is easy enough using the MS example:
    >
    > private void DataGrid1_ItemDataBound(object sender,
    > System.Web.UI.WebControls.DataGridItemEventArgs e)
    > {
    > ListItemType itemType = e.Item.ItemType;
    > if ((itemType == ListItemType.Pager) ||
    > (itemType == ListItemType.Header) ||
    > (itemType == ListItemType.Footer))
    > {
    > return;
    > }
    > LinkButton button = (LinkButton)e.Item.Cells[0].Controls[0];
    > e.Item.Attributes["onclick"] =
    > Page.GetPostBackClientHyperlink(button, "");
    > }
    >
    > But, how is an entire column selected?
    >
    > -David
     
    Prasad, Sep 3, 2003
    #4
  5. wireless

    David Brown Guest

    "If you want to select the Column by clicking on the Column Header what
    you can do is Set AllowSorting to True and based on the SortExpression
    value you can determine which column select."

    Yes, I've done this just but I use sorting for sorting and need a
    different column highlighted rather than the sorted one.

    "2. Can you be more specific abt how you want to select a Column"

    I want the user to be able to select (highlight) a column in the same
    way a row is selected, that is, by clicking anywhere in the column.

    -David


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    David Brown, Sep 3, 2003
    #5
    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. reiks

    datagrid highlight

    reiks, Dec 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    466
    reiks
    Dec 30, 2003
  2. TJS
    Replies:
    1
    Views:
    3,295
    =?Utf-8?B?QW5hbmQgTW9oYW4=?=
    Feb 17, 2004
  3. =?Utf-8?B?YmFjazJncmlk?=

    highlight datagrid row on radiobutton selection

    =?Utf-8?B?YmFjazJncmlk?=, Sep 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    473
    =?Utf-8?B?YmFjazJncmlk?=
    Sep 13, 2004
  4. Peter
    Replies:
    0
    Views:
    482
    Peter
    Sep 9, 2004
  5. John Smith

    Highlight column

    John Smith, Feb 13, 2004, in forum: HTML
    Replies:
    13
    Views:
    10,603
    Toby A Inkster
    Feb 15, 2004
Loading...

Share This Page