Customizing pager/header/footer

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Customizing pager/header/footer

    I need to put web controls inside pager, header or footer
    parts of the datagrid. Any ideas?


    Tumurbaatar S. Guest

  2. Similar Questions and Discussions

    1. adding button to header, footer or Pager of dataGrid
      hi i want to know whether is it possible to add button (say DELETE button) in the header,footer or Pager of a dataGrid? If yes,how do i achieve...
    2. Header & Footer Help
      I am trying to add a header to my PDF. When I go to the toolbar - document - and click on add/update/remove, nothing happens. I am not getting a pop...
    3. cfdocument with header & footer
      Well, I got it working using CFHTTP, throwing in a couple of comment tags I can check for to filter out the header and footer, but it's really silly...
    4. ASCX as Header/Footer
      Hello, I want to create a Header and Footer for every ASPX page I build. I created 2 Web user controls respectively and placed them in an ASPX...
    5. include() header and footer
      I'm ashamed that I need to ask this question. I've been using PHP for almost a year now, and have used HTML extensively in the last few years. ...
  3. #2

    Default Re: Customizing pager/header/footer

    Hi,

    In the ItemDataBound event of the datagrid, you can add the controls to the
    datagrid header cells programmatically, or you can take a look at
    HeaderTemplates.

    Instead of giving you a link, I'll just give you the google search URL:

    [url]http://www.google.com/search?q=asp.net+datagrid+headertemplate&btnG=Sear ch&hs=Gpg&hl=en&lr=&safe=off&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial[/url]

    HTH

    -Altaf
    --------------------------------------------------------------------------------
    All that glitters has a high refractive index.
    [url]www.mendhak.com[/url]


    "Tumurbaatar S." <spam_tumur@magicnet.mn> wrote in message
    news:u%23w5PxQ4FHA.1416@TK2MSFTNGP09.phx.gbl...
    >I need to put web controls inside pager, header or footer
    > parts of the datagrid. Any ideas?
    >
    >

    S.M. Altaf [MVP] Guest

  4. #3

    Default Re: Customizing pager/header/footer

    Thank you!
    I've added controls to my datagrid's footer and pager. And now I can
    customize them at item's Create or DataBound events. But I cannot find
    a method to access these controls after, for example, after postback.
    DataGrid.Items contains only normal item rows. The header/footer/pagers
    are not included in this collection. My datagrid has several controls
    on the footer row and I do postback using some button. And within
    this button's Click event handler I need to examine content of these
    controls. Any ideas?
    Also, in several articles about adding controls to the pager, for example,
    I saw that before dynamically adding a control, authors check out whether
    this control was added in prior round trips. They says that the datagrid
    can save previously added control and without checking this, it may
    lead to duplicate controls. In my code I don't check it and all work
    normally: no duplicated/doubled controls. Anybody can explain this?



    "S.M. Altaf [MVP]" <smaltaf@PLEASEDONTSPAMMEmsn.com> wrote in message
    news:exVJbhU4FHA.1140@tk2msftngp13.phx.gbl...
    > Hi,
    >
    > In the ItemDataBound event of the datagrid, you can add the controls to
    > the datagrid header cells programmatically, or you can take a look at
    > HeaderTemplates.
    >
    > Instead of giving you a link, I'll just give you the google search URL:
    >
    > [url]http://www.google.com/search?q=asp.net+datagrid+headertemplate&btnG=Sear ch&hs=Gpg&hl=en&lr=&safe=off&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial[/url]
    >
    > HTH
    >
    > -Altaf
    > --------------------------------------------------------------------------------
    > All that glitters has a high refractive index.
    > [url]www.mendhak.com[/url]
    >
    >
    > "Tumurbaatar S." <spam_tumur@magicnet.mn> wrote in message
    > news:u%23w5PxQ4FHA.1416@TK2MSFTNGP09.phx.gbl...
    >>I need to put web controls inside pager, header or footer
    >> parts of the datagrid. Any ideas?
    >>
    >>
    >
    >

    Tumurbaatar S. Guest

  5. #4

    Default Re: Customizing pager/header/footer

    That isn't very difficult.

    Loop through the DataGridItemCollection. Start by looking for ItemType =
    Header. In the header, you can go through each cell and do a .FindControl()
    for the control that you have in your header (and assuming you have given
    each control an ID). CTYpe() the control to the control type that you put
    there, and then access the values that you want.

    HTH
    ALtaf
    --------------------------------------------------------------------------------
    All that glitters has a high refractive index.
    [url]www.mendhak.com[/url]


    "Tumurbaatar S." <spam_tumur@magicnet.mn> wrote in message
    news:%237j1C$E5FHA.692@TK2MSFTNGP11.phx.gbl...
    > Thank you!
    > I've added controls to my datagrid's footer and pager. And now I can
    > customize them at item's Create or DataBound events. But I cannot find
    > a method to access these controls after, for example, after postback.
    > DataGrid.Items contains only normal item rows. The header/footer/pagers
    > are not included in this collection. My datagrid has several controls
    > on the footer row and I do postback using some button. And within
    > this button's Click event handler I need to examine content of these
    > controls. Any ideas?
    > Also, in several articles about adding controls to the pager, for example,
    > I saw that before dynamically adding a control, authors check out whether
    > this control was added in prior round trips. They says that the datagrid
    > can save previously added control and without checking this, it may
    > lead to duplicate controls. In my code I don't check it and all work
    > normally: no duplicated/doubled controls. Anybody can explain this?
    >
    >
    >
    > "S.M. Altaf [MVP]" <smaltaf@PLEASEDONTSPAMMEmsn.com> wrote in message
    > news:exVJbhU4FHA.1140@tk2msftngp13.phx.gbl...
    >> Hi,
    >>
    >> In the ItemDataBound event of the datagrid, you can add the controls to
    >> the datagrid header cells programmatically, or you can take a look at
    >> HeaderTemplates.
    >>
    >> Instead of giving you a link, I'll just give you the google search URL:
    >>
    >> [url]http://www.google.com/search?q=asp.net+datagrid+headertemplate&btnG=Sear ch&hs=Gpg&hl=en&lr=&safe=off&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial[/url]
    >>
    >> HTH
    >>
    >> -Altaf
    >> --------------------------------------------------------------------------------
    >> All that glitters has a high refractive index.
    >> [url]www.mendhak.com[/url]
    >>
    >>
    >> "Tumurbaatar S." <spam_tumur@magicnet.mn> wrote in message
    >> news:u%23w5PxQ4FHA.1416@TK2MSFTNGP09.phx.gbl...
    >>>I need to put web controls inside pager, header or footer
    >>> parts of the datagrid. Any ideas?
    >>>
    >>>
    >>
    >>
    >
    >

    S.M. Altaf [MVP] Guest

  6. #5

    Default Re: Customizing pager/header/footer

    From MSDN/.NET Reference:
    "...Note Only items bound to the data source are contained in the
    Items collection. The header, footer, and separator are not included in
    the collection....".

    What collection do you mean?


    "S.M. Altaf [MVP]" <smaltaf@PLEASEDONTSPAMMEmsn.com> wrote in message
    news:Oaeti3G5FHA.1028@TK2MSFTNGP11.phx.gbl...
    > That isn't very difficult.
    >
    > Loop through the DataGridItemCollection. Start by looking for ItemType =
    > Header. In the header, you can go through each cell and do a
    > .FindControl() for the control that you have in your header (and assuming
    > you have given each control an ID). CTYpe() the control to the control
    > type that you put there, and then access the values that you want.
    >
    > HTH
    > ALtaf
    > --------------------------------------------------------------------------------
    > All that glitters has a high refractive index.
    > [url]www.mendhak.com[/url]
    >
    >
    > "Tumurbaatar S." <spam_tumur@magicnet.mn> wrote in message
    > news:%237j1C$E5FHA.692@TK2MSFTNGP11.phx.gbl...
    >> Thank you!
    >> I've added controls to my datagrid's footer and pager. And now I can
    >> customize them at item's Create or DataBound events. But I cannot find
    >> a method to access these controls after, for example, after postback.
    >> DataGrid.Items contains only normal item rows. The header/footer/pagers
    >> are not included in this collection. My datagrid has several controls
    >> on the footer row and I do postback using some button. And within
    >> this button's Click event handler I need to examine content of these
    >> controls. Any ideas?
    >> Also, in several articles about adding controls to the pager, for
    >> example,
    >> I saw that before dynamically adding a control, authors check out whether
    >> this control was added in prior round trips. They says that the datagrid
    >> can save previously added control and without checking this, it may
    >> lead to duplicate controls. In my code I don't check it and all work
    >> normally: no duplicated/doubled controls. Anybody can explain this?
    >>
    >>
    >>
    >> "S.M. Altaf [MVP]" <smaltaf@PLEASEDONTSPAMMEmsn.com> wrote in message
    >> news:exVJbhU4FHA.1140@tk2msftngp13.phx.gbl...
    >>> Hi,
    >>>
    >>> In the ItemDataBound event of the datagrid, you can add the controls to
    >>> the datagrid header cells programmatically, or you can take a look at
    >>> HeaderTemplates.
    >>>
    >>> Instead of giving you a link, I'll just give you the google search URL:
    >>>
    >>> [url]http://www.google.com/search?q=asp.net+datagrid+headertemplate&btnG=Sear ch&hs=Gpg&hl=en&lr=&safe=off&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial[/url]
    >>>
    >>> HTH
    >>>
    >>> -Altaf
    >>> --------------------------------------------------------------------------------
    >>> All that glitters has a high refractive index.
    >>> [url]www.mendhak.com[/url]
    >>>
    >>>
    >>> "Tumurbaatar S." <spam_tumur@magicnet.mn> wrote in message
    >>> news:u%23w5PxQ4FHA.1416@TK2MSFTNGP09.phx.gbl...
    >>>>I need to put web controls inside pager, header or footer
    >>>> parts of the datagrid. Any ideas?
    >>>>
    >>>>
    >>>
    >>>
    >>
    >>
    >
    >

    Tumurbaatar S. Guest

  7. #6

    Default Re: Customizing pager/header/footer

    Hi, Tumurbaatar. You are right. Only data-bound items are included in the
    Items collection. For instance, to accessing LinkButton control in the

    1. Header
    DataGridItem item = (DataGridItem)DataGrid1.Controls[0].Controls[0];
    LinkButton lbtnHeader = (LinkButton)item.FindControl("lbtnInHeader");


    1. Footer
    DataGridItem item =
    (DataGridItem)DataGrid1.Controls[0].Controls[DataGrid1.Controls[0].Controls.Count-2];
    LinkButton lbtnFooter = (LinkButton)item.FindControl("lbtnInFooter");


    1. Pager
    DataGridItem item =
    (DataGridItem)DataGrid1.Controls[0].Controls[DataGrid1.Controls[0].Controls.Count-1];
    LinkButton lbtnPager = (LinkButton)item.FindControl("lbtnInPager");


    The DataGrid1.Controls[0] refers to the DataGridTable in the page hierarchy
    control tree. Take note that, if the pager is implemented, the footer is the
    second last DataGridItem control, otherwise I would be the last one, always.


    Hope this helps...
    alvinz_c Guest

  8. #7

    Default Re: Customizing pager/header/footer

    Got an error: Specified argument was out of the range of valid values.
    Parameter name: index.

    On the 1st Page_Load event my DataGrid is empty.
    DataGrid1.Controls.Count returns 0, i.e. DataGrid1.Controls[0]
    does not exist.
    Why?
    There's a DropDownList in my DataGrid's footer and I need
    to populate list items from the Page_Load().
    Referencing DataGrid1.Controls[0] after postback works:
    no exception raised, items populated normally.


    "alvinz_c" <alvinzc@discussions.microsoft.com> wrote in message
    news:6445E26A-21A6-4F2C-A6C0-0ECCCAE538E5@microsoft.com...
    > Hi, Tumurbaatar. You are right. Only data-bound items are included in the
    > Items collection. For instance, to accessing LinkButton control in the
    >
    > 1. Header
    > DataGridItem item = (DataGridItem)DataGrid1.Controls[0].Controls[0];
    > LinkButton lbtnHeader = (LinkButton)item.FindControl("lbtnInHeader");
    >
    >
    > 1. Footer
    > DataGridItem item =
    > (DataGridItem)DataGrid1.Controls[0].Controls[DataGrid1.Controls[0].Controls.Count-2];
    > LinkButton lbtnFooter = (LinkButton)item.FindControl("lbtnInFooter");
    >
    >
    > 1. Pager
    > DataGridItem item =
    > (DataGridItem)DataGrid1.Controls[0].Controls[DataGrid1.Controls[0].Controls.Count-1];
    > LinkButton lbtnPager = (LinkButton)item.FindControl("lbtnInPager");
    >
    >
    > The DataGrid1.Controls[0] refers to the DataGridTable in the page
    > hierarchy
    > control tree. Take note that, if the pager is implemented, the footer is
    > the
    > second last DataGridItem control, otherwise I would be the last one,
    > always.
    >
    >
    > Hope this helps...

    Tumurbaatar S. Guest

Posting Permissions

  • You may not post new threads
  • You may 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