473,740 Members | 9,506 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Find footer labels in DataGrid

How do I find (and set) a couple of labels in the Footer after a DataGrid is
filled?

I have a bunch of DataGrids that get displayed nested inside a DataList.

The datagrid looks like:

*************** *************** *************** *************** *************** ****
<asp:DataGrid visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateCol umns="False"
GridLines="None "
ShowFooter="tru e"
onItemDataBound ="DataGrid1_Ite mDataBound"
OnItemCommand=" DataInsert"
onEditCommand=" DataEdit"
onCancelCommand ="DataCancel "
onUpdateCommand ="DataUpdate ">
<AlternatingIte mStyle BorderWidth="0p x" BorderStyle="No ne"
BorderColor="Wh ite" BackColor="line n"></AlternatingItem Style>
<HeaderStyle Font-Bold="True" BackColor="#669 9cc"></HeaderStyle>
<Columns>
<asp:TemplateCo lumn HeaderText="Ans wer">
<ItemTemplate >
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Answe r") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:TextBox id="txtAnswerFo oter" runat="server"> </asp:TextBox>
</FooterTemplate>
<EditItemTempla te>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Answe r") %>'>
</asp:textbox>
</EditItemTemplat e>
</asp:templateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblPosition ID" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Posit ionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblPosition IDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblQuestion Unique" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Quest ionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblQuestion UniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Answ erUnique" visible="false" ReadOnly="true"
HeaderText="Ans werUnique"></asp:BoundColumn >
<asp:EditComman dColumn EditText="<img src='..\images\ Edit.png'border ='0'
id='textbox1'>" visible="true"
ButtonType="Lin kButton"
UpdateText="<im g src='..\images\ update.png' border='0'>"
CancelText="<im g src='..\images\ Cancel.png' border='0'>" />
<asp:TemplateCo lumn >
<FooterTemplate >
<asp:LinkButt on CommandName="In sert" Text="<img
src='..\images\ Add.gif'border= '0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate >
<asp:LinkButt on CommandName="De lete" Text="<img
src='..\images\ Delete.gif'bord er='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
*************** *************** *************** *************** *************** ************

I have the DataGrid by doing something like:

for each oItem as DataListItem in DataList1.Items
Dim oGrid as DataGrid = CType(oItem.Fin dControl("DataG rid1"),DataGrid )

How would I use oGrid to find and set "lblPositionIDF ooter" and
"lblQuestionUni queFooter"?

I need this as I need a place to put the PositionID and QuestionUnique as
they are keys I need to use in my Insert statement. I am inserting rows
from the Footer and need to get these variables from some where, so this
seems to be the most logical place to store them.

Thanks,

Tom.
Nov 18 '05 #1
9 5063
Try: e.Item.FindCont rol("lblPositio nIDFooter)

Sonu

-----Original Message-----
How do I find (and set) a couple of labels in the Footer after a DataGrid isfilled?

I have a bunch of DataGrids that get displayed nested inside a DataList.
The datagrid looks like:

************** *************** *************** ************** *************** ******<asp:DataGri d visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateCol umns="False"
GridLines="None "
ShowFooter="tru e"
onItemDataBound ="DataGrid1_Ite mDataBound"
OnItemCommand=" DataInsert"
onEditCommand=" DataEdit"
onCancelCommand ="DataCancel "
onUpdateCommand ="DataUpdate ">
<AlternatingIte mStyle BorderWidth="0p x" BorderStyle="No ne"BorderColor="W hite" BackColor="line n"></AlternatingItem Style> <HeaderStyle Font-Bold="True" BackColor="#669 9cc"></HeaderStyle> <Columns>
<asp:TemplateCo lumn HeaderText="Ans wer">
<ItemTemplate >
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:TextBox id="txtAnswerFo oter" runat="server"> </asp:TextBox> </FooterTemplate>
<EditItemTempla te>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
</asp:textbox>
</EditItemTemplat e>
</asp:templateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblPosition ID" runat="server" Text='<% #DataBinder.Eva l(Container, "DataItem.Posit ionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblPosition IDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblQuestion Unique" runat="server" Text='<%#DataBinder.Eva l(Container, "DataItem.Quest ionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblQuestion UniqueFooter" runat="server"> </asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Answ erUnique" visible="false" ReadOnly="true"HeaderText="An swerUnique"></asp:BoundColumn >
<asp:EditComman dColumn EditText="<img src='..\images\ Edit.png'border ='0'id='textbox1'> " visible="true"
ButtonType="Lin kButton"
UpdateText="<im g src='..\images\ update.png' border='0'>"CancelText="<i mg src='..\images\ Cancel.png' border='0'>" /> <asp:TemplateCo lumn >
<FooterTemplate >
<asp:LinkButt on CommandName="In sert" Text="<img
src='..\images \Add.gif'border ='0'>" ID="btnAdd" Runat="server" /> </FooterTemplate>
<ItemTemplate >
<asp:LinkButt on CommandName="De lete" Text="<img
src='..\images \Delete.gif'bor der='0'>" ID="btnDel" Runat="server" /> </ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
************** *************** *************** ************** *************** **************
I have the DataGrid by doing something like:

for each oItem as DataListItem in DataList1.Items
Dim oGrid as DataGrid = CType(oItem.Fin dControl ("DataGrid1"),D ataGrid)
How would I use oGrid to find and set "lblPositionIDF ooter" and"lblQuestionUn iqueFooter"?

I need this as I need a place to put the PositionID and QuestionUnique asthey are keys I need to use in my Insert statement. I am inserting rowsfrom the Footer and need to get these variables from some where, so thisseems to be the most logical place to store them.

Thanks,

Tom.
.

Nov 18 '05 #2
First you need to check whether that datagrid item is footer, then you can
use e.item.cells(<c orrespondingcel l index>.findcont rol(<your control name>)
method to find your label control. For more details, refer this link
http://www.extremeexperts.com/Net/Ar...stoFooter.aspx

--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"tshad" <ts**********@f tsolutions.com> wrote in message
news:OU******** ******@TK2MSFTN GP09.phx.gbl...
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled?

I have a bunch of DataGrids that get displayed nested inside a DataList.

The datagrid looks like:

*************** *************** *************** *************** *************** *
*** <asp:DataGrid visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateCol umns="False"
GridLines="None "
ShowFooter="tru e"
onItemDataBound ="DataGrid1_Ite mDataBound"
OnItemCommand=" DataInsert"
onEditCommand=" DataEdit"
onCancelCommand ="DataCancel "
onUpdateCommand ="DataUpdate ">
<AlternatingIte mStyle BorderWidth="0p x" BorderStyle="No ne"
BorderColor="Wh ite" BackColor="line n"></AlternatingItem Style>
<HeaderStyle Font-Bold="True" BackColor="#669 9cc"></HeaderStyle>
<Columns>
<asp:TemplateCo lumn HeaderText="Ans wer">
<ItemTemplate >
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Answe r") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:TextBox id="txtAnswerFo oter" runat="server"> </asp:TextBox>
</FooterTemplate>
<EditItemTempla te>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Answe r") %>'>
</asp:textbox>
</EditItemTemplat e>
</asp:templateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblPosition ID" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Posit ionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblPosition IDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblQuestion Unique" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Quest ionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblQuestion UniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Answ erUnique" visible="false" ReadOnly="true" HeaderText="Ans werUnique"></asp:BoundColumn >
<asp:EditComman dColumn EditText="<img src='..\images\ Edit.png'border ='0'
id='textbox1'>" visible="true"
ButtonType="Lin kButton"
UpdateText="<im g src='..\images\ update.png' border='0'>"
CancelText="<im g src='..\images\ Cancel.png' border='0'>" />
<asp:TemplateCo lumn >
<FooterTemplate >
<asp:LinkButt on CommandName="In sert" Text="<img
src='..\images\ Add.gif'border= '0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate >
<asp:LinkButt on CommandName="De lete" Text="<img
src='..\images\ Delete.gif'bord er='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
*************** *************** *************** *************** *************** *
***********
I have the DataGrid by doing something like:

for each oItem as DataListItem in DataList1.Items
Dim oGrid as DataGrid = CType(oItem.Fin dControl("DataG rid1"),DataGrid )

How would I use oGrid to find and set "lblPositionIDF ooter" and
"lblQuestionUni queFooter"?

I need this as I need a place to put the PositionID and QuestionUnique as
they are keys I need to use in my Insert statement. I am inserting rows
from the Footer and need to get these variables from some where, so this
seems to be the most logical place to store them.

Thanks,

Tom.

Nov 18 '05 #3
Hi tshad:

You might want to try during the ItemDataBound event instead (check
for e.Item.ItemType == ListItemType.Fo oter).

If you need to wait until afterwards, then you can index into the
Controls collection of the grid. (The Items collection might look
tempting at first, but it only contains DataGridItems bound to
records, the header and footer items appear only in the Controls
collection). The footer item should be in the last element of the
Controls array.

I have some examples about 1/2 through this article:
http://www.odetocode.com/Articles/116.aspx

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/


On Tue, 2 Nov 2004 17:14:06 -0800, "tshad"
<ts**********@f tsolutions.com> wrote:
How do I find (and set) a couple of labels in the Footer after a DataGrid is
filled?

I have a bunch of DataGrids that get displayed nested inside a DataList.

The datagrid looks like:

************** *************** *************** *************** *************** *****
<asp:DataGri d visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateCol umns="False"
GridLines="None "
ShowFooter="tru e"
onItemDataBound ="DataGrid1_Ite mDataBound"
OnItemCommand=" DataInsert"
onEditCommand=" DataEdit"
onCancelCommand ="DataCancel "
onUpdateCommand ="DataUpdate ">
<AlternatingIte mStyle BorderWidth="0p x" BorderStyle="No ne"
BorderColor="W hite" BackColor="line n"></AlternatingItem Style>
<HeaderStyle Font-Bold="True" BackColor="#669 9cc"></HeaderStyle>
<Columns>
<asp:TemplateCo lumn HeaderText="Ans wer">
<ItemTemplate >
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:TextBox id="txtAnswerFo oter" runat="server"> </asp:TextBox>
</FooterTemplate>
<EditItemTempla te>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
</asp:textbox>
</EditItemTemplat e>
</asp:templateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblPosition ID" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Posit ionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblPosition IDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblQuestion Unique" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Quest ionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblQuestion UniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Answ erUnique" visible="false" ReadOnly="true"
HeaderText="An swerUnique"></asp:BoundColumn >
<asp:EditComman dColumn EditText="<img src='..\images\ Edit.png'border ='0'
id='textbox1'> " visible="true"
ButtonType="Lin kButton"
UpdateText="<im g src='..\images\ update.png' border='0'>"
CancelText="<i mg src='..\images\ Cancel.png' border='0'>" />
<asp:TemplateCo lumn >
<FooterTemplate >
<asp:LinkButt on CommandName="In sert" Text="<img
src='..\images \Add.gif'border ='0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate >
<asp:LinkButt on CommandName="De lete" Text="<img
src='..\images \Delete.gif'bor der='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
************** *************** *************** *************** *************** *************

I have the DataGrid by doing something like:

for each oItem as DataListItem in DataList1.Items
Dim oGrid as DataGrid = CType(oItem.Fin dControl("DataG rid1"),DataGrid )

How would I use oGrid to find and set "lblPositionIDF ooter" and
"lblQuestionUn iqueFooter"?

I need this as I need a place to put the PositionID and QuestionUnique as
they are keys I need to use in my Insert statement. I am inserting rows
from the Footer and need to get these variables from some where, so this
seems to be the most logical place to store them.

Thanks,

Tom.


Nov 18 '05 #4
"Sonu Kapoor" <so********@gma il.com> wrote in message
news:39******** *************** *****@phx.gbl.. .
Try: e.Item.FindCont rol("lblPositio nIDFooter)
I can't use e.item as the object is a datalist that has a datagrid in it. I
then find the oGrid from that.

So I tried:

Dim fPositionID as Label = oGrid.Item.Find Control("lblPos itionIDFooter")

and got the following error message:
*************** *************** *************** ***
Compiler Error Message: BC30456: 'Item' is not a member of
'System.Web.UI. WebControls.Dat aGrid'.

Source Error:

Line 225: Dim oCollapse as ImageButton =
CType(DataList1 .Items(DataList 1.SelectedIndex ).FindControl(" CollapseButton" )
,ImageButton)
Line 226:
Line 227: Dim fPositionID as Label =
oGrid.Item.Find Control("lblPos itionIDFooter")
*************** *************** *************** *************** *****

Tom.
Sonu

-----Original Message-----
How do I find (and set) a couple of labels in the Footer

after a DataGrid is
filled?

I have a bunch of DataGrids that get displayed nested

inside a DataList.

The datagrid looks like:

************** *************** *************** **************

*************** ******
<asp:DataGri d visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateCol umns="False"
GridLines="None "
ShowFooter="tru e"
onItemDataBound ="DataGrid1_Ite mDataBound"
OnItemCommand=" DataInsert"
onEditCommand=" DataEdit"
onCancelCommand ="DataCancel "
onUpdateCommand ="DataUpdate ">
<AlternatingIte mStyle BorderWidth="0p x"

BorderStyle="No ne"
BorderColor="W hite"

BackColor="line n"></AlternatingItem Style>
<HeaderStyle Font-Bold="True"

BackColor="#669 9cc"></HeaderStyle>
<Columns>
<asp:TemplateCo lumn HeaderText="Ans wer">
<ItemTemplate >
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:TextBox id="txtAnswerFo oter"

runat="server"> </asp:TextBox>
</FooterTemplate>
<EditItemTempla te>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
</asp:textbox>
</EditItemTemplat e>
</asp:templateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblPosition ID" runat="server" Text='<%

#
DataBinder.Eva l(Container, "DataItem.Posit ionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblPosition IDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblQuestion Unique" runat="server"

Text='<%#
DataBinder.Eva l(Container, "DataItem.Quest ionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblQuestion UniqueFooter"

runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Answ erUnique"

visible="false" ReadOnly="true"
HeaderText="An swerUnique"></asp:BoundColumn >
<asp:EditComman dColumn EditText="<img

src='..\images\ Edit.png'border ='0'
id='textbox1'> " visible="true"
ButtonType="Lin kButton"
UpdateText="<im g src='..\images\ update.png'

border='0'>"
CancelText="<i mg src='..\images\ Cancel.png'

border='0'>" />
<asp:TemplateCo lumn >
<FooterTemplate >
<asp:LinkButt on CommandName="In sert" Text="<img
src='..\images \Add.gif'border ='0'>" ID="btnAdd"

Runat="server" />
</FooterTemplate>
<ItemTemplate >
<asp:LinkButt on CommandName="De lete" Text="<img
src='..\images \Delete.gif'bor der='0'>" ID="btnDel"

Runat="server" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
************** *************** *************** **************

*************** **************

I have the DataGrid by doing something like:

for each oItem as DataListItem in DataList1.Items
Dim oGrid as DataGrid = CType(oItem.Fin dControl

("DataGrid1"),D ataGrid)

How would I use oGrid to find and

set "lblPositionIDF ooter" and
"lblQuestionUn iqueFooter"?

I need this as I need a place to put the PositionID and

QuestionUnique as
they are keys I need to use in my Insert statement. I am

inserting rows
from the Footer and need to get these variables from some

where, so this
seems to be the most logical place to store them.

Thanks,

Tom.
.

Nov 18 '05 #5
"Saravana" <sa******@sct.c o.in> wrote in message
news:yD******** ********@news.c pqcorp.net...
First you need to check whether that datagrid item is footer, then you can
use e.item.cells(<c orrespondingcel l index>.findcont rol(<your control name>) method to find your label control. For more details, refer this link
http://www.extremeexperts.com/Net/Ar...stoFooter.aspx
I already know I have a footer and I have the Grid object. I just don't
know how to get to a label that is already in the footer.

Tom.
--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"tshad" <ts**********@f tsolutions.com> wrote in message
news:OU******** ******@TK2MSFTN GP09.phx.gbl...
How do I find (and set) a couple of labels in the Footer after a DataGrid
is
filled?

I have a bunch of DataGrids that get displayed nested inside a DataList.

The datagrid looks like:

*************** *************** *************** *************** *************** * ***
<asp:DataGrid visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateCol umns="False"
GridLines="None "
ShowFooter="tru e"
onItemDataBound ="DataGrid1_Ite mDataBound"
OnItemCommand=" DataInsert"
onEditCommand=" DataEdit"
onCancelCommand ="DataCancel "
onUpdateCommand ="DataUpdate ">
<AlternatingIte mStyle BorderWidth="0p x" BorderStyle="No ne"
BorderColor="Wh ite" BackColor="line n"></AlternatingItem Style>
<HeaderStyle Font-Bold="True" BackColor="#669 9cc"></HeaderStyle>
<Columns>
<asp:TemplateCo lumn HeaderText="Ans wer">
<ItemTemplate >
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Answe r") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:TextBox id="txtAnswerFo oter" runat="server"> </asp:TextBox>
</FooterTemplate>
<EditItemTempla te>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Answe r") %>'>
</asp:textbox>
</EditItemTemplat e>
</asp:templateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblPosition ID" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Posit ionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblPosition IDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblQuestion Unique" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Quest ionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblQuestion UniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Answ erUnique" visible="false" ReadOnly="true"
HeaderText="Ans werUnique"></asp:BoundColumn >
<asp:EditComman dColumn EditText="<img

src='..\images\ Edit.png'border ='0' id='textbox1'>" visible="true"
ButtonType="Lin kButton"
UpdateText="<im g src='..\images\ update.png' border='0'>"
CancelText="<im g src='..\images\ Cancel.png' border='0'>" />
<asp:TemplateCo lumn >
<FooterTemplate >
<asp:LinkButt on CommandName="In sert" Text="<img
src='..\images\ Add.gif'border= '0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate >
<asp:LinkButt on CommandName="De lete" Text="<img
src='..\images\ Delete.gif'bord er='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>

*************** *************** *************** *************** *************** * ***********

I have the DataGrid by doing something like:

for each oItem as DataListItem in DataList1.Items
Dim oGrid as DataGrid = CType(oItem.Fin dControl("DataG rid1"),DataGrid )
How would I use oGrid to find and set "lblPositionIDF ooter" and
"lblQuestionUni queFooter"?

I need this as I need a place to put the PositionID and QuestionUnique as they are keys I need to use in my Insert statement. I am inserting rows
from the Footer and need to get these variables from some where, so this
seems to be the most logical place to store them.

Thanks,

Tom.


Nov 18 '05 #6
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:og******** *************** *********@4ax.c om...
Hi tshad:

You might want to try during the ItemDataBound event instead (check
for e.Item.ItemType == ListItemType.Fo oter).

If you need to wait until afterwards, then you can index into the
Controls collection of the grid. (The Items collection might look
tempting at first, but it only contains DataGridItems bound to
records, the header and footer items appear only in the Controls
collection). The footer item should be in the last element of the
Controls array.

I have some examples about 1/2 through this article:
http://www.odetocode.com/Articles/116.aspx
I tried some of what you had and here is what I came up with.

The routine where I need to get access to the label in the footer is:

*************** *************** *************** *************** **********
Sub OnSelectIndexCh anged(sender as Object,e as DataListCommand EventArgs)
if e.CommandName = "Select" then
DataList1.Selec tedIndex = e.Item.ItemInde x
end if

Dim oGrid as DataGrid =
CType(DataList1 .Items(DataList 1.SelectedIndex ).FindControl(" DataGrid1"),Dat a
Grid)

Dim lblPositionIDF as Label =
oGrid.Controls( 0).Controls(0). FindControl("lb lPositionIDFoot er")
*************** *************** *************** *************** **********

Gives me the following error:

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

The DataGrid footer section looks like:

*************** *************** *************** *************** **********
<asp:TemplateCo lumn visible="true">
<ItemTemplate >
<asp:Label id="lblPosition ID" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Posit ionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblPosition IDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
*************** *************** *************** *************** **********

This doesn't seem to be it, unless I am missing something (and I probably
am).

Thanks,

Tom.

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/


On Tue, 2 Nov 2004 17:14:06 -0800, "tshad"
<ts**********@f tsolutions.com> wrote:
How do I find (and set) a couple of labels in the Footer after a DataGrid isfilled?

I have a bunch of DataGrids that get displayed nested inside a DataList.

The datagrid looks like:


************** *************** *************** *************** *************** *

****
<asp:DataGri d visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateCol umns="False"
GridLines="None "
ShowFooter="tru e"
onItemDataBound ="DataGrid1_Ite mDataBound"
OnItemCommand=" DataInsert"
onEditCommand=" DataEdit"
onCancelCommand ="DataCancel "
onUpdateCommand ="DataUpdate ">
<AlternatingIte mStyle BorderWidth="0p x" BorderStyle="No ne"
BorderColor="W hite" BackColor="line n"></AlternatingItem Style>
<HeaderStyle Font-Bold="True" BackColor="#669 9cc"></HeaderStyle>
<Columns>
<asp:TemplateCo lumn HeaderText="Ans wer">
<ItemTemplate >
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:TextBox id="txtAnswerFo oter" runat="server"> </asp:TextBox>
</FooterTemplate>
<EditItemTempla te>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
</asp:textbox>
</EditItemTemplat e>
</asp:templateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblPosition ID" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Posit ionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblPosition IDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblQuestion Unique" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Quest ionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblQuestion UniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Answ erUnique" visible="false" ReadOnly="true"HeaderText="An swerUnique"></asp:BoundColumn >
<asp:EditComman dColumn EditText="<img src='..\images\ Edit.png'border ='0'id='textbox1'> " visible="true"
ButtonType="Lin kButton"
UpdateText="<im g src='..\images\ update.png' border='0'>"
CancelText="<i mg src='..\images\ Cancel.png' border='0'>" />
<asp:TemplateCo lumn >
<FooterTemplate >
<asp:LinkButt on CommandName="In sert" Text="<img
src='..\images \Add.gif'border ='0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate >
<asp:LinkButt on CommandName="De lete" Text="<img
src='..\images \Delete.gif'bor der='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>


************** *************** *************** *************** *************** *

************

I have the DataGrid by doing something like:

for each oItem as DataListItem in DataList1.Items
Dim oGrid as DataGrid = CType(oItem.Fin dControl("DataG rid1"),DataGrid )
How would I use oGrid to find and set "lblPositionIDF ooter" and
"lblQuestionUn iqueFooter"?

I need this as I need a place to put the PositionID and QuestionUnique as
they are keys I need to use in my Insert statement. I am inserting rows
from the Footer and need to get these variables from some where, so this
seems to be the most logical place to store them.

Thanks,

Tom.

Nov 18 '05 #7
tshad,

After a week or two of trying to solve a similar issue, I stumbles upon your
post.

Alleluia! I believe I am on my way to solving my problem. I'll post back in
a couple of hours and let you know if this really was it.

I have a datagrid with 2 nested datagrids. Here is a screenshot.
http://www.smartbizniz.com/ee/SBS_Va..._EE_Sample.pdf

I am using the footers of the nested datagrids to add new records. It was
easy for the users to push the Add link to add records one by one. They got
tired of that and wanted to add new records a page at a time.

I could loop through the records in the master datagrid and get at the
nested datagrid but I couldn't figure out how to get the values in the nested
datagrid's footer. Now I have it:

Private Sub btnTest_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnTest.Click

Dim strText As String

For Each item As DataGridItem In DataGrid1.Items

Dim dgTemp As DataGrid = CType(item.Find Control("DataGr id_PTD"),
DataGrid)
Dim txt As TextBox =
CType(dgTemp.Co ntrols(0).Contr ols(1).FindCont rol("txtPTDsNar rativeAdd"),
TextBox)
If txt Is Nothing Then
strText = ""
Else
strText = txt.Text
End If

'Now add a new record to the dataset
Next

End Sub

Have you been able to solve your problem?

"tshad" wrote:
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:og******** *************** *********@4ax.c om...
Hi tshad:

You might want to try during the ItemDataBound event instead (check
for e.Item.ItemType == ListItemType.Fo oter).

If you need to wait until afterwards, then you can index into the
Controls collection of the grid. (The Items collection might look
tempting at first, but it only contains DataGridItems bound to
records, the header and footer items appear only in the Controls
collection). The footer item should be in the last element of the
Controls array.

I have some examples about 1/2 through this article:
http://www.odetocode.com/Articles/116.aspx


I tried some of what you had and here is what I came up with.

The routine where I need to get access to the label in the footer is:

*************** *************** *************** *************** **********
Sub OnSelectIndexCh anged(sender as Object,e as DataListCommand EventArgs)
if e.CommandName = "Select" then
DataList1.Selec tedIndex = e.Item.ItemInde x
end if

Dim oGrid as DataGrid =
CType(DataList1 .Items(DataList 1.SelectedIndex ).FindControl(" DataGrid1"),Dat a
Grid)

Dim lblPositionIDF as Label =
oGrid.Controls( 0).Controls(0). FindControl("lb lPositionIDFoot er")
*************** *************** *************** *************** **********

Gives me the following error:

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

The DataGrid footer section looks like:

*************** *************** *************** *************** **********
<asp:TemplateCo lumn visible="true">
<ItemTemplate >
<asp:Label id="lblPosition ID" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Posit ionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblPosition IDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
*************** *************** *************** *************** **********

This doesn't seem to be it, unless I am missing something (and I probably
am).

Thanks,

Tom.

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/


On Tue, 2 Nov 2004 17:14:06 -0800, "tshad"
<ts**********@f tsolutions.com> wrote:
How do I find (and set) a couple of labels in the Footer after a DataGrid isfilled?

I have a bunch of DataGrids that get displayed nested inside a DataList.

The datagrid looks like:


************** *************** *************** *************** *************** *

****
<asp:DataGri d visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateCol umns="False"
GridLines="None "
ShowFooter="tru e"
onItemDataBound ="DataGrid1_Ite mDataBound"
OnItemCommand=" DataInsert"
onEditCommand=" DataEdit"
onCancelCommand ="DataCancel "
onUpdateCommand ="DataUpdate ">
<AlternatingIte mStyle BorderWidth="0p x" BorderStyle="No ne"
BorderColor="W hite" BackColor="line n"></AlternatingItem Style>
<HeaderStyle Font-Bold="True" BackColor="#669 9cc"></HeaderStyle>
<Columns>
<asp:TemplateCo lumn HeaderText="Ans wer">
<ItemTemplate >
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:TextBox id="txtAnswerFo oter" runat="server"> </asp:TextBox>
</FooterTemplate>
<EditItemTempla te>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
</asp:textbox>
</EditItemTemplat e>
</asp:templateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblPosition ID" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Posit ionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblPosition IDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblQuestion Unique" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Quest ionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblQuestion UniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Answ erUnique" visible="false" ReadOnly="true"HeaderText="An swerUnique"></asp:BoundColumn >
<asp:EditComman dColumn EditText="<img src='..\images\ Edit.png'border ='0'id='textbox1'> " visible="true"
ButtonType="Lin kButton"
UpdateText="<im g src='..\images\ update.png' border='0'>"
CancelText="<i mg src='..\images\ Cancel.png' border='0'>" />
<asp:TemplateCo lumn >
<FooterTemplate >
<asp:LinkButt on CommandName="In sert" Text="<img
src='..\images \Add.gif'border ='0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate >
<asp:LinkButt on CommandName="De lete" Text="<img
src='..\images \Delete.gif'bor der='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>


************** *************** *************** *************** *************** *

************

I have the DataGrid by doing something like:

for each oItem as DataListItem in DataList1.Items
Dim oGrid as DataGrid = CType(oItem.Fin dControl("DataG rid1"),DataGrid )
How would I use oGrid to find and set "lblPositionIDF ooter" and
"lblQuestionUn iqueFooter"?

I need this as I need a place to put the PositionID and QuestionUnique as
they are keys I need to use in my Insert statement. I am inserting rows
from the Footer and need to get these variables from some where, so this
seems to be the most logical place to store them.

Thanks,

Tom.


Nov 18 '05 #8
tshad:

This was it!

It took a little while for me to realize that the index for the footer
control changes depending on how many records are in the datagrid. However,
in my case it is always the last control.

Hope you were able to solve your problem.

Here is my code:

Private Sub btnTest_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnTest.Click

Dim strNarrativePTD As String
Dim strNarrativeYTD As String
Dim intFooterPTD As Integer
Dim intFooterYTD As Integer
Dim intNarrativeTyp e As Int16
Dim intSortOrder As Integer = 1 'Sort order has not been implemented yet

For Each item As DataGridItem In DataGrid1.Items

Dim dgPTD As DataGrid = CType(item.Find Control("DataGr id_PTD"),
DataGrid)
Dim dgYTD As DataGrid = CType(item.Find Control("DataGr id_YTD"),
DataGrid)

'The Footer section is the last control in the nested datagrid. We
will use this index later.
intFooterPTD = dgPTD.Controls( 0).Controls.Cou nt - 1
intFooterYTD = dgYTD.Controls( 0).Controls.Cou nt - 1

'First check the PTD Comments
Dim txtPTD As TextBox =
CType(dgPTD.Con trols(0).Contro ls(intFooterPTD ).FindControl(" txtPTDsNarrativ eAdd"), TextBox)
Dim lblPTD As Label =
CType(dgPTD.Con trols(0).Contro ls(intFooterPTD ).FindControl(" lblhAcctPTDAdd" ),
Label)
If txtPTD Is Nothing Then
strNarrativePTD = ""
Else
strNarrativePTD = txtPTD.Text
strHAcct = lblPTD.Text
intNarrativeTyp e = 1
End If

'If there is something in the textbox, add the record.
If Len(strNarrativ ePTD) > 0 Then
NarrativesAdd(i ntNarrativeType , strNarrativePTD , intSortOrder)
End If

'Second check the YTD Comments
Dim txtYTD As TextBox =
CType(dgYTD.Con trols(0).Contro ls(intFooterYTD ).FindControl(" txtYTDsNarrativ eAdd"), TextBox)
Dim lblYTD As Label =
CType(dgYTD.Con trols(0).Contro ls(intFooterYTD ).FindControl(" lblhAcctYTDAdd" ),
Label)
If txtYTD Is Nothing Then
strNarrativeYTD = ""
Else
strNarrativeYTD = txtYTD.Text
strHAcct = lblYTD.Text
intNarrativeTyp e = 12
End If

'If there is something in the textbox, add the record.
If Len(strNarrativ eYTD) > 0 Then
NarrativesAdd(i ntNarrativeType , strNarrativeYTD , intSortOrder)
End If

Next

LoadGrid()

End Sub

"tshad" wrote:
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:og******** *************** *********@4ax.c om...
Hi tshad:

You might want to try during the ItemDataBound event instead (check
for e.Item.ItemType == ListItemType.Fo oter).

If you need to wait until afterwards, then you can index into the
Controls collection of the grid. (The Items collection might look
tempting at first, but it only contains DataGridItems bound to
records, the header and footer items appear only in the Controls
collection). The footer item should be in the last element of the
Controls array.

I have some examples about 1/2 through this article:
http://www.odetocode.com/Articles/116.aspx


I tried some of what you had and here is what I came up with.

The routine where I need to get access to the label in the footer is:

*************** *************** *************** *************** **********
Sub OnSelectIndexCh anged(sender as Object,e as DataListCommand EventArgs)
if e.CommandName = "Select" then
DataList1.Selec tedIndex = e.Item.ItemInde x
end if

Dim oGrid as DataGrid =
CType(DataList1 .Items(DataList 1.SelectedIndex ).FindControl(" DataGrid1"),Dat a
Grid)

Dim lblPositionIDF as Label =
oGrid.Controls( 0).Controls(0). FindControl("lb lPositionIDFoot er")
*************** *************** *************** *************** **********

Gives me the following error:

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

The DataGrid footer section looks like:

*************** *************** *************** *************** **********
<asp:TemplateCo lumn visible="true">
<ItemTemplate >
<asp:Label id="lblPosition ID" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Posit ionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblPosition IDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
*************** *************** *************** *************** **********

This doesn't seem to be it, unless I am missing something (and I probably
am).

Thanks,

Tom.

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/


On Tue, 2 Nov 2004 17:14:06 -0800, "tshad"
<ts**********@f tsolutions.com> wrote:
How do I find (and set) a couple of labels in the Footer after a DataGrid isfilled?

I have a bunch of DataGrids that get displayed nested inside a DataList.

The datagrid looks like:


************** *************** *************** *************** *************** *

****
<asp:DataGri d visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateCol umns="False"
GridLines="None "
ShowFooter="tru e"
onItemDataBound ="DataGrid1_Ite mDataBound"
OnItemCommand=" DataInsert"
onEditCommand=" DataEdit"
onCancelCommand ="DataCancel "
onUpdateCommand ="DataUpdate ">
<AlternatingIte mStyle BorderWidth="0p x" BorderStyle="No ne"
BorderColor="W hite" BackColor="line n"></AlternatingItem Style>
<HeaderStyle Font-Bold="True" BackColor="#669 9cc"></HeaderStyle>
<Columns>
<asp:TemplateCo lumn HeaderText="Ans wer">
<ItemTemplate >
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:TextBox id="txtAnswerFo oter" runat="server"> </asp:TextBox>
</FooterTemplate>
<EditItemTempla te>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
</asp:textbox>
</EditItemTemplat e>
</asp:templateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblPosition ID" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Posit ionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblPosition IDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn >
<ItemTemplate >
<asp:Label id="lblQuestion Unique" runat="server" Text='<%#
DataBinder.Eva l(Container, "DataItem.Quest ionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblQuestion UniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Answ erUnique" visible="false" ReadOnly="true"HeaderText="An swerUnique"></asp:BoundColumn >
<asp:EditComman dColumn EditText="<img src='..\images\ Edit.png'border ='0'id='textbox1'> " visible="true"
ButtonType="Lin kButton"
UpdateText="<im g src='..\images\ update.png' border='0'>"
CancelText="<i mg src='..\images\ Cancel.png' border='0'>" />
<asp:TemplateCo lumn >
<FooterTemplate >
<asp:LinkButt on CommandName="In sert" Text="<img
src='..\images \Add.gif'border ='0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate >
<asp:LinkButt on CommandName="De lete" Text="<img
src='..\images \Delete.gif'bor der='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>


************** *************** *************** *************** *************** *

************

I have the DataGrid by doing something like:

for each oItem as DataListItem in DataList1.Items
Dim oGrid as DataGrid = CType(oItem.Fin dControl("DataG rid1"),DataGrid )
How would I use oGrid to find and set "lblPositionIDF ooter" and
"lblQuestionUn iqueFooter"?

I need this as I need a place to put the PositionID and QuestionUnique as
they are keys I need to use in my Insert statement. I am inserting rows
from the Footer and need to get these variables from some where, so this
seems to be the most logical place to store them.

Thanks,

Tom.


Nov 18 '05 #9
"John Desautels" <John De*******@discu ssions.microsof t.com> wrote in message
news:C4******** *************** ***********@mic rosoft.com...
tshad:

This was it!

It took a little while for me to realize that the index for the footer
control changes depending on how many records are in the datagrid.
However,
in my case it is always the last control.

Hope you were able to solve your problem.
Actually,

I did. But not the way I wanted to.

The problem was I have multiple grids inside of a datalist. Each grid was a
different set up records differentiated by a unique number. My problem is
finding out what the unique number was.

I figured I would just look through the datalist until I find the datagrid
that matched the name of the one I was using. I know that the table ID's
would be different when the page was rendered. What I didn't realize that
in ASP, before it is rendered, all the ID's are identical. So that didn't
work.

What I ended up doing was puting the unique number in a hidden column on the
footer as the table was being populated. Then when I did the insert I would
already be pointing at the Footer and I could get the data easily at that
point.

What I haven't been able to do was figure out how to find out which Datalist
row (the parent) is equated with the Datagrid I am working with. I assume I
will have the same problem - same name.

Thanks,

Tom.
Here is my code:

Private Sub btnTest_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnTest.Click

Dim strNarrativePTD As String
Dim strNarrativeYTD As String
Dim intFooterPTD As Integer
Dim intFooterYTD As Integer
Dim intNarrativeTyp e As Int16
Dim intSortOrder As Integer = 1 'Sort order has not been implemented
yet

For Each item As DataGridItem In DataGrid1.Items

Dim dgPTD As DataGrid = CType(item.Find Control("DataGr id_PTD"),
DataGrid)
Dim dgYTD As DataGrid = CType(item.Find Control("DataGr id_YTD"),
DataGrid)

'The Footer section is the last control in the nested datagrid. We
will use this index later.
intFooterPTD = dgPTD.Controls( 0).Controls.Cou nt - 1
intFooterYTD = dgYTD.Controls( 0).Controls.Cou nt - 1

'First check the PTD Comments
Dim txtPTD As TextBox =
CType(dgPTD.Con trols(0).Contro ls(intFooterPTD ).FindControl(" txtPTDsNarrativ eAdd"),
TextBox)
Dim lblPTD As Label =
CType(dgPTD.Con trols(0).Contro ls(intFooterPTD ).FindControl(" lblhAcctPTDAdd" ),
Label)
If txtPTD Is Nothing Then
strNarrativePTD = ""
Else
strNarrativePTD = txtPTD.Text
strHAcct = lblPTD.Text
intNarrativeTyp e = 1
End If

'If there is something in the textbox, add the record.
If Len(strNarrativ ePTD) > 0 Then
NarrativesAdd(i ntNarrativeType , strNarrativePTD , intSortOrder)
End If

'Second check the YTD Comments
Dim txtYTD As TextBox =
CType(dgYTD.Con trols(0).Contro ls(intFooterYTD ).FindControl(" txtYTDsNarrativ eAdd"),
TextBox)
Dim lblYTD As Label =
CType(dgYTD.Con trols(0).Contro ls(intFooterYTD ).FindControl(" lblhAcctYTDAdd" ),
Label)
If txtYTD Is Nothing Then
strNarrativeYTD = ""
Else
strNarrativeYTD = txtYTD.Text
strHAcct = lblYTD.Text
intNarrativeTyp e = 12
End If

'If there is something in the textbox, add the record.
If Len(strNarrativ eYTD) > 0 Then
NarrativesAdd(i ntNarrativeType , strNarrativeYTD , intSortOrder)
End If

Next

LoadGrid()

End Sub

"tshad" wrote:
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:og******** *************** *********@4ax.c om...
> Hi tshad:
>
> You might want to try during the ItemDataBound event instead (check
> for e.Item.ItemType == ListItemType.Fo oter).
>
> If you need to wait until afterwards, then you can index into the
> Controls collection of the grid. (The Items collection might look
> tempting at first, but it only contains DataGridItems bound to
> records, the header and footer items appear only in the Controls
> collection). The footer item should be in the last element of the
> Controls array.
>
> I have some examples about 1/2 through this article:
> http://www.odetocode.com/Articles/116.aspx


I tried some of what you had and here is what I came up with.

The routine where I need to get access to the label in the footer is:

*************** *************** *************** *************** **********
Sub OnSelectIndexCh anged(sender as Object,e as DataListCommand EventArgs)
if e.CommandName = "Select" then
DataList1.Selec tedIndex = e.Item.ItemInde x
end if

Dim oGrid as DataGrid =
CType(DataList1 .Items(DataList 1.SelectedIndex ).FindControl(" DataGrid1"),Dat a
Grid)

Dim lblPositionIDF as Label =
oGrid.Controls( 0).Controls(0). FindControl("lb lPositionIDFoot er")
*************** *************** *************** *************** **********

Gives me the following error:

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

The DataGrid footer section looks like:

*************** *************** *************** *************** **********
<asp:TemplateCo lumn visible="true">
<ItemTemplate >
<asp:Label id="lblPosition ID" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Posit ionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:Label id="lblPosition IDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateCol umn>
*************** *************** *************** *************** **********

This doesn't seem to be it, unless I am missing something (and I probably
am).

Thanks,

Tom.
>
> HTH,
>
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
>
>
>
>
> On Tue, 2 Nov 2004 17:14:06 -0800, "tshad"
> <ts**********@f tsolutions.com> wrote:
>
> >How do I find (and set) a couple of labels in the Footer after a
> >DataGrid

is
> >filled?
> >
> >I have a bunch of DataGrids that get displayed nested inside a
> >DataList.
> >
> >The datagrid looks like:
> >
>
>************** *************** *************** *************** *************** *

****
> ><asp:DataGri d visible="False"
> > border=1
> > id="DataGrid1"
> > runat="server"
> > Width="400px"
> > Height="79px"
> > AutoGenerateCol umns="False"
> > GridLines="None "
> > ShowFooter="tru e"
> > onItemDataBound ="DataGrid1_Ite mDataBound"
> > OnItemCommand=" DataInsert"
> > onEditCommand=" DataEdit"
> > onCancelCommand ="DataCancel "
> > onUpdateCommand ="DataUpdate ">
> > <AlternatingIte mStyle BorderWidth="0p x" BorderStyle="No ne"
> >BorderColor="W hite" BackColor="line n"></AlternatingItem Style>
> > <HeaderStyle Font-Bold="True" BackColor="#669 9cc"></HeaderStyle>
> > <Columns>
> > <asp:TemplateCo lumn HeaderText="Ans wer">
> > <ItemTemplate >
> > <asp:Label id="lblAnswer" runat="server" Text='<%#
> >DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
> > </asp:Label>
> > </ItemTemplate>
> > <FooterTemplate >
> > <asp:TextBox id="txtAnswerFo oter" runat="server"> </asp:TextBox>
> > </FooterTemplate>
> > <EditItemTempla te>
> > <asp:textbox id="txtAnswer" runat="server" Text='<%#
> >DataBinder.Eva l(Container, "DataItem.Answe r") %>'>
> > </asp:textbox>
> > </EditItemTemplat e>
> > </asp:templateCol umn>
> > <asp:TemplateCo lumn >
> > <ItemTemplate >
> > <asp:Label id="lblPosition ID" runat="server" Text='<%#
> >DataBinder.Eva l(Container, "DataItem.Posit ionID") %>'>
> > </asp:Label>
> > </ItemTemplate>
> > <FooterTemplate >
> > <asp:Label id="lblPosition IDFooter" runat="server">
> > </asp:Label>
> > </FooterTemplate>
> > </asp:TemplateCol umn>
> > <asp:TemplateCo lumn >
> > <ItemTemplate >
> > <asp:Label id="lblQuestion Unique" runat="server" Text='<%#
> >DataBinder.Eva l(Container, "DataItem.Quest ionUnique") %>'>
> > </asp:Label>
> > </ItemTemplate>
> > <FooterTemplate >
> > <asp:Label id="lblQuestion UniqueFooter" runat="server">
> > </asp:Label>
> > </FooterTemplate>
> > </asp:TemplateCol umn>
> > <asp:BoundColum n DataField="Answ erUnique" visible="false"

ReadOnly="true"
> >HeaderText="An swerUnique"></asp:BoundColumn >
> > <asp:EditComman dColumn EditText="<img

src='..\images\ Edit.png'border ='0'
> >id='textbox1'> " visible="true"
> > ButtonType="Lin kButton"
> > UpdateText="<im g src='..\images\ update.png' border='0'>"
> >CancelText="<i mg src='..\images\ Cancel.png' border='0'>" />
> > <asp:TemplateCo lumn >
> > <FooterTemplate >
> > <asp:LinkButt on CommandName="In sert" Text="<img
> >src='..\images \Add.gif'border ='0'>" ID="btnAdd" Runat="server" />
> > </FooterTemplate>
> > <ItemTemplate >
> > <asp:LinkButt on CommandName="De lete" Text="<img
> >src='..\images \Delete.gif'bor der='0'>" ID="btnDel" Runat="server" />
> > </ItemTemplate>
> > </asp:TemplateCol umn>
> > </Columns>
> ></asp:DataGrid>
>
>************** *************** *************** *************** *************** *

************
> >
> >I have the DataGrid by doing something like:
> >
> > for each oItem as DataListItem in DataList1.Items
> > Dim oGrid as DataGrid =

CType(oItem.Fin dControl("DataG rid1"),DataGrid )
> >
> >How would I use oGrid to find and set "lblPositionIDF ooter" and
> >"lblQuestionUn iqueFooter"?
> >
> >I need this as I need a place to put the PositionID and QuestionUnique
> >as
> >they are keys I need to use in my Insert statement. I am inserting
> >rows
> >from the Footer and need to get these variables from some where, so
> >this
> >seems to be the most logical place to store them.
> >
> >Thanks,
> >
> >Tom.
> >
>


Nov 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
350
by: Randy | last post by:
Can footers be forced to the bottom of an .ASPX page either using #include or User Controls? I got a page that starts out displaying 3 drop down lists, one text box, 5 labels and 1 Submit Button. The goal is to initially have the footer display below the Submit Button. Once data has been filled in, a DataGrid will display data based on the criteria. The drop downs work, the DataGrid displays data correctly. The problem is that when I...
0
1232
by: Robert Ashby | last post by:
I have a .jpg footer on my .aspx web page. When the datagrid loads it floats over the top of the web page footer. The footer does not move. I would like to footer to float on the web page and adjust according to the datagrid. If the datagrid is showing only 3 items or 20 items I would like the .jpg footer always to be at the bottom of the datagrid. How can I do this?? Thanks for the help
2
7155
by: Galina | last post by:
Hello I have a report, which lists records. Each record has money paid field. Money paid can be 0 or not 0. I calculate and print summary of money for a group in the group footer, as well as summary of money for all groups the report footer. When there is at least one record with money >0, group and report footers are appropriate and look OK. When all records are with 0 money, footers look silly. I’d like not to print them. I have placed...
2
1458
by: | last post by:
I have gotten the following error in trying to get totals to come out on a footer. Server Error in '/test' Application. ---------------------------------------------------------------------------- ---- DataBinder.Eval: 'System.Data.Common.DbDataRecord' does not contain a property with the name ViewCount. Description: An unhandled exception occurred during the execution of the
3
1412
by: mark | last post by:
im keeping running totals of certain columns in a datagrid, id like to put these totals in the footer - how do i do this ? or how can i put a label into the footer ? (im displaying results using labels instead at the moment) eg Label5.Text = "Column 1 Total:- " & mordraw & " (Ratio " & FormatNumber(ddpercent, 2) "%)"
4
34528
by: huzz | last post by:
I am trying to access a DropDownList control inside a repeater using ItemCommand as shown below but for some reason i can't access the DropDownList. When i step through the debug i get <undefine value> for the DropDownList What am i doing wrong? <asp:Repeater ID="Repeater1" Runat="server" OnItemDataBound="create_ddl" OnItemCommand="Repeater1_ItemCommand"> <HeaderTemplate>
2
1508
by: Neo Geshel | last post by:
After pouring over about a dozen sites that clearly dealt with ClientID all by itself, I came to the realization that about 2/3+ of them were doing it wrong. It is indeed impossible to grab the Client ID of a form field from within a DataGrid like this: <%= FormFieldID.ClientID %>. At least, not without extra work. How did I do this? I created a new DataGrid from scratch, with a form above it and a form inside of it. This was a page...
1
1666
by: Stu | last post by:
Hi, I have a button in the footer of a datagrid that sometimes does not tigger the item command. The page is quite large & has a number of homegrown controls in it. Has anyone come across this type of behaviour before? Can anyone suggest a solution? Thanks in advance, Stu
3
6067
by: williamfrenette | last post by:
To add record into my grid I use the footer way like explain here : http://aspnet.4guysfromrolla.com/articles/021203-1.aspx But i dont want a Add button on each row so i call the showfooter with another button. DBEditDataGrid.ShowFooter := true; DBEditDataGrid.SelectedIndex := DBEditDataGrid.Items.Count; LoadDataFromDB; DataBindGrid;
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9272
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9211
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8218
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6756
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6056
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4572
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.