Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Tumurbaatar S. #1
Customizing pager/header/footer
I need to put web controls inside pager, header or footer
parts of the datagrid. Any ideas?
Tumurbaatar S. Guest
-
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... -
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... -
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... -
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... -
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. ... -
S.M. Altaf [MVP] #2
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
-
Tumurbaatar S. #3
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
-
S.M. Altaf [MVP] #4
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
-
Tumurbaatar S. #5
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
-
alvinz_c #6
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
-
Tumurbaatar S. #7
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



Reply With Quote

