Professional Web Applications Themes

Droplist in Header of DataGrid. Possible? - ASP.NET Data Grid Control

Is it possible to locate a droplist inside the header of a column next to the headertext? The droplist is created independent of the datagrid and is not related to the data in the grid itself. Has anyone done this? TD...

  1. #1

    Default Droplist in Header of DataGrid. Possible?

    Is it possible to locate a droplist inside the header of a column next
    to the headertext?

    The droplist is created independent of the datagrid and is not related
    to the data in the grid itself.

    Has anyone done this?

    TD
    hoosierprogrammer@yahoo.com Guest

  2. #2

    Default Re: Droplist in Header of DataGrid. Possible?

    just add the control to the header item in the itemdatabound event
    e.item.cells[23].controls.add(droppdownlist1);
    roughly

    --
    Regards,
    Alvin Bruney
    [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
    Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
    <hoosierprogrammer> wrote in message
    news:a8b6ca34.0409021039.1f464bf7posting.google.c om...
    > Is it possible to locate a droplist inside the header of a column next
    > to the headertext?
    >
    > The droplist is created independent of the datagrid and is not related
    > to the data in the grid itself.
    >
    > Has anyone done this?
    >
    > TD

    Alvin Bruney [MVP] Guest

  3. #3

    Default Re: Droplist in Header of DataGrid. Possible?

    Thanks Alvin,

    That got me pointed in the right direction. A little trouble though.

    With this code (below), the single column datagrid disappears except
    for the header and it does not have the dropdown in it. I'm pretty
    sure that it is firing because when I comment it out, the grid
    reappears.

    Thoughts?

    Thanks for your help.

    TD



    protected void DGridAllGroupList_ItemDataBound(object sender,
    System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    e.Item.Cells[0].Text = "Test";
    e.Item.Cells[0].Controls.Add(ddGroup);

    }





















    "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message news:<OX820eTkEHA.3452TK2MSFTNGP15.phx.gbl>...
    > just add the control to the header item in the itemdatabound event
    > e.item.cells[23].controls.add(droppdownlist1);
    > roughly
    >
    > --
    > Regards,
    > Alvin Bruney
    > [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
    > Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
    > <hoosierprogrammer> wrote in message
    > news:a8b6ca34.0409021039.1f464bf7posting.google.c om...
    > > Is it possible to locate a droplist inside the header of a column next
    > > to the headertext?
    > >
    > > The droplist is created independent of the datagrid and is not related
    > > to the data in the grid itself.
    > >
    > > Has anyone done this?
    > >
    > > TD
    hoosierprogrammer@yahoo.com Guest

  4. #4

    Default Re: Droplist in Header of DataGrid. Possible?

    you need to only put the control in the header not the other cells
    change your code to

    if(e.Item.ItemType == ListItemType.Header)

    {
    > e.Item.Cells[0].Text = "Test";
    > e.Item.Cells[0].Controls.Add(ddGroup);
    }


    --
    Regards,
    Alvin Bruney
    [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
    Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
    <hoosierprogrammer> wrote in message
    news:a8b6ca34.0409030628.7d682818posting.google.c om...
    > Thanks Alvin,
    >
    > That got me pointed in the right direction. A little trouble though.
    >
    > With this code (below), the single column datagrid disappears except
    > for the header and it does not have the dropdown in it. I'm pretty
    > sure that it is firing because when I comment it out, the grid
    > reappears.
    >
    > Thoughts?
    >
    > Thanks for your help.
    >
    > TD
    >
    >
    >
    > protected void DGridAllGroupList_ItemDataBound(object sender,
    > System.Web.UI.WebControls.DataGridItemEventArgs e)
    > {
    > e.Item.Cells[0].Text = "Test";
    > e.Item.Cells[0].Controls.Add(ddGroup);
    >
    > }
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    > news:<OX820eTkEHA.3452TK2MSFTNGP15.phx.gbl>...
    >> just add the control to the header item in the itemdatabound event
    >> e.item.cells[23].controls.add(droppdownlist1);
    >> roughly
    >>
    >> --
    >> Regards,
    >> Alvin Bruney
    >> [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
    >> Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
    >> <hoosierprogrammer> wrote in message
    >> news:a8b6ca34.0409021039.1f464bf7posting.google.c om...
    >> > Is it possible to locate a droplist inside the header of a column next
    >> > to the headertext?
    >> >
    >> > The droplist is created independent of the datagrid and is not related
    >> > to the data in the grid itself.
    >> >
    >> > Has anyone done this?
    >> >
    >> > TD

    Alvin Bruney [MVP] Guest

  5. #5

    Default Re: Droplist in Header of DataGrid. Possible?

    PERFECT !

    I'm not quite sure why the cell index needs to be 1 (I was thinking
    0), but that's anohter issue.

    Thanks for your help. Here's the final code.

    TD


    protected void DGridAllGroupList_ItemDataBound(object sender,
    System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType == ListItemType.Header)
    {
    e.Item.Cells[1].HorizontalAlign = HorizontalAlign.Right;
    e.Item.Cells[1].Controls.Add(ddGroup);
    }
    }









    "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message news:<upPeOdckEHA.2504TK2MSFTNGP14.phx.gbl>...
    > you need to only put the control in the header not the other cells
    > change your code to
    >
    > if(e.Item.ItemType == ListItemType.Header)
    >
    > {
    >
    > > e.Item.Cells[0].Text = "Test";
    > > e.Item.Cells[0].Controls.Add(ddGroup);
    > }
    >
    >
    > --
    > Regards,
    > Alvin Bruney
    > [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
    > Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
    > <hoosierprogrammer> wrote in message
    > news:a8b6ca34.0409030628.7d682818posting.google.c om...
    > > Thanks Alvin,
    > >
    > > That got me pointed in the right direction. A little trouble though.
    > >
    > > With this code (below), the single column datagrid disappears except
    > > for the header and it does not have the dropdown in it. I'm pretty
    > > sure that it is firing because when I comment it out, the grid
    > > reappears.
    > >
    > > Thoughts?
    > >
    > > Thanks for your help.
    > >
    > > TD
    > >
    > >
    > >
    > > protected void DGridAllGroupList_ItemDataBound(object sender,
    > > System.Web.UI.WebControls.DataGridItemEventArgs e)
    > > {
    > > e.Item.Cells[0].Text = "Test";
    > > e.Item.Cells[0].Controls.Add(ddGroup);
    > >
    > > }
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    > > news:<OX820eTkEHA.3452TK2MSFTNGP15.phx.gbl>...
    > >> just add the control to the header item in the itemdatabound event
    > >> e.item.cells[23].controls.add(droppdownlist1);
    > >> roughly
    > >>
    > >> --
    > >> Regards,
    > >> Alvin Bruney
    > >> [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
    > >> Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
    > >> <hoosierprogrammer> wrote in message
    > >> news:a8b6ca34.0409021039.1f464bf7posting.google.c om...
    > >> > Is it possible to locate a droplist inside the header of a column next
    > >> > to the headertext?
    > >> >
    > >> > The droplist is created independent of the datagrid and is not related
    > >> > to the data in the grid itself.
    > >> >
    > >> > Has anyone done this?
    > >> >
    > >> > TD
    hoosierprogrammer@yahoo.com Guest

  6. #6

    Default Re: Droplist in Header of DataGrid. Possible?

    if you have a select button in index 0 then you need to start counting at 1

    --
    Regards,
    Alvin Bruney
    [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
    Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
    <hoosierprogrammer> wrote in message
    news:a8b6ca34.0409040333.5608357aposting.google.c om...
    > PERFECT !
    >
    > I'm not quite sure why the cell index needs to be 1 (I was thinking
    > 0), but that's anohter issue.
    >
    > Thanks for your help. Here's the final code.
    >
    > TD
    >
    >
    > protected void DGridAllGroupList_ItemDataBound(object sender,
    > System.Web.UI.WebControls.DataGridItemEventArgs e)
    > {
    > if(e.Item.ItemType == ListItemType.Header)
    > {
    > e.Item.Cells[1].HorizontalAlign = HorizontalAlign.Right;
    > e.Item.Cells[1].Controls.Add(ddGroup);
    > }
    > }
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    > news:<upPeOdckEHA.2504TK2MSFTNGP14.phx.gbl>...
    >> you need to only put the control in the header not the other cells
    >> change your code to
    >>
    >> if(e.Item.ItemType == ListItemType.Header)
    >>
    >> {
    >>
    >> > e.Item.Cells[0].Text = "Test";
    >> > e.Item.Cells[0].Controls.Add(ddGroup);
    >> }
    >>
    >>
    >> --
    >> Regards,
    >> Alvin Bruney
    >> [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
    >> Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
    >> <hoosierprogrammer> wrote in message
    >> news:a8b6ca34.0409030628.7d682818posting.google.c om...
    >> > Thanks Alvin,
    >> >
    >> > That got me pointed in the right direction. A little trouble though.
    >> >
    >> > With this code (below), the single column datagrid disappears except
    >> > for the header and it does not have the dropdown in it. I'm pretty
    >> > sure that it is firing because when I comment it out, the grid
    >> > reappears.
    >> >
    >> > Thoughts?
    >> >
    >> > Thanks for your help.
    >> >
    >> > TD
    >> >
    >> >
    >> >
    >> > protected void DGridAllGroupList_ItemDataBound(object sender,
    >> > System.Web.UI.WebControls.DataGridItemEventArgs e)
    >> > {
    >> > e.Item.Cells[0].Text = "Test";
    >> > e.Item.Cells[0].Controls.Add(ddGroup);
    >> >
    >> > }
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> > "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    >> > news:<OX820eTkEHA.3452TK2MSFTNGP15.phx.gbl>...
    >> >> just add the control to the header item in the itemdatabound event
    >> >> e.item.cells[23].controls.add(droppdownlist1);
    >> >> roughly
    >> >>
    >> >> --
    >> >> Regards,
    >> >> Alvin Bruney
    >> >> [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
    >> >> Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
    >> >> <hoosierprogrammer> wrote in message
    >> >> news:a8b6ca34.0409021039.1f464bf7posting.google.c om...
    >> >> > Is it possible to locate a droplist inside the header of a column
    >> >> > next
    >> >> > to the headertext?
    >> >> >
    >> >> > The droplist is created independent of the datagrid and is not
    >> >> > related
    >> >> > to the data in the grid itself.
    >> >> >
    >> >> > Has anyone done this?
    >> >> >
    >> >> > TD

    Alvin Bruney [MVP] Guest

Similar Threads

  1. Hiding header in datagrid
    By bill.snapper@gmail.com in forum Macromedia Flex General Discussion
    Replies: 1
    Last Post: March 31st, 09:35 AM
  2. datagrid header
    By Cambridgeways in forum ASP.NET Data Grid Control
    Replies: 2
    Last Post: January 24th, 04:31 AM
  3. adding droplist as column from returned Dataset
    By Meir Rotfleisch in forum ASP.NET Web Services
    Replies: 0
    Last Post: November 30th, 08:52 AM
  4. DataGrid Column Header
    By Prabhu Kumar Maramreddy in forum ASP.NET Building Controls
    Replies: 2
    Last Post: September 1st, 03:50 PM
  5. DataGrid header and <TH>
    By Bassel Tabbara [MSFT] in forum ASP.NET General
    Replies: 1
    Last Post: June 27th, 07:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139