473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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"
AutoGenerateColumns="False"
GridLines="None"
ShowFooter="true"
onItemDataBound="DataGrid1_ItemDataBound"
OnItemCommand="DataInsert"
onEditCommand="DataEdit"
onCancelCommand="DataCancel"
onUpdateCommand="DataUpdate">
<AlternatingItemStyle BorderWidth="0px" BorderStyle="None"
BorderColor="White" BackColor="linen"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" BackColor="#6699cc"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Answer">
<ItemTemplate>
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAnswerFooter" runat="server"></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:textbox>
</EditItemTemplate>
</asp:templateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblPositionID" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.PositionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblPositionIDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblQuestionUnique" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.QuestionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblQuestionUniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="AnswerUnique" visible="false" ReadOnly="true"
HeaderText="AnswerUnique"></asp:BoundColumn>
<asp:EditCommandColumn EditText="<img src='..\images\Edit.png'border='0'
id='textbox1'>" visible="true"
ButtonType="LinkButton"
UpdateText="<img src='..\images\update.png' border='0'>"
CancelText="<img src='..\images\Cancel.png' border='0'>" />
<asp:TemplateColumn >
<FooterTemplate>
<asp:LinkButton CommandName="Insert" Text="<img
src='..\images\Add.gif'border='0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton CommandName="Delete" Text="<img
src='..\images\Delete.gif'border='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</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.FindControl("DataGrid1"),DataGrid)

How would I use oGrid to find and set "lblPositionIDFooter" and
"lblQuestionUniqueFooter"?

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 5030
Try: e.Item.FindControl("lblPositionIDFooter)

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:DataGrid visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateColumns="False"
GridLines="None"
ShowFooter="true"
onItemDataBound="DataGrid1_ItemDataBound"
OnItemCommand="DataInsert"
onEditCommand="DataEdit"
onCancelCommand="DataCancel"
onUpdateCommand="DataUpdate">
<AlternatingItemStyle BorderWidth="0px" BorderStyle="None"BorderColor="White" BackColor="linen"></AlternatingItemStyle> <HeaderStyle Font-Bold="True" BackColor="#6699cc"></HeaderStyle> <Columns>
<asp:TemplateColumn HeaderText="Answer">
<ItemTemplate>
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAnswerFooter" runat="server"></asp:TextBox> </FooterTemplate>
<EditItemTemplate>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:textbox>
</EditItemTemplate>
</asp:templateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblPositionID" runat="server" Text='<% #DataBinder.Eval(Container, "DataItem.PositionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblPositionIDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblQuestionUnique" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.QuestionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblQuestionUniqueFooter" runat="server"> </asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="AnswerUnique" visible="false" ReadOnly="true"HeaderText="AnswerUnique"></asp:BoundColumn>
<asp:EditCommandColumn EditText="<img src='..\images\Edit.png'border='0'id='textbox1'>" visible="true"
ButtonType="LinkButton"
UpdateText="<img src='..\images\update.png' border='0'>"CancelText="<img src='..\images\Cancel.png' border='0'>" /> <asp:TemplateColumn >
<FooterTemplate>
<asp:LinkButton CommandName="Insert" Text="<img
src='..\images\Add.gif'border='0'>" ID="btnAdd" Runat="server" /> </FooterTemplate>
<ItemTemplate>
<asp:LinkButton CommandName="Delete" Text="<img
src='..\images\Delete.gif'border='0'>" ID="btnDel" Runat="server" /> </ItemTemplate>
</asp:TemplateColumn>
</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.FindControl ("DataGrid1"),DataGrid)
How would I use oGrid to find and set "lblPositionIDFooter" and"lblQuestionUniqueFooter"?

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(<correspondingcell index>.findcontrol(<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**********@ftsolutions.com> wrote in message
news:OU**************@TK2MSFTNGP09.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"
AutoGenerateColumns="False"
GridLines="None"
ShowFooter="true"
onItemDataBound="DataGrid1_ItemDataBound"
OnItemCommand="DataInsert"
onEditCommand="DataEdit"
onCancelCommand="DataCancel"
onUpdateCommand="DataUpdate">
<AlternatingItemStyle BorderWidth="0px" BorderStyle="None"
BorderColor="White" BackColor="linen"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" BackColor="#6699cc"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Answer">
<ItemTemplate>
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAnswerFooter" runat="server"></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:textbox>
</EditItemTemplate>
</asp:templateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblPositionID" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.PositionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblPositionIDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblQuestionUnique" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.QuestionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblQuestionUniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="AnswerUnique" visible="false" ReadOnly="true" HeaderText="AnswerUnique"></asp:BoundColumn>
<asp:EditCommandColumn EditText="<img src='..\images\Edit.png'border='0'
id='textbox1'>" visible="true"
ButtonType="LinkButton"
UpdateText="<img src='..\images\update.png' border='0'>"
CancelText="<img src='..\images\Cancel.png' border='0'>" />
<asp:TemplateColumn >
<FooterTemplate>
<asp:LinkButton CommandName="Insert" Text="<img
src='..\images\Add.gif'border='0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton CommandName="Delete" Text="<img
src='..\images\Delete.gif'border='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</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.FindControl("DataGrid1"),DataGrid)

How would I use oGrid to find and set "lblPositionIDFooter" and
"lblQuestionUniqueFooter"?

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.Footer).

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**********@ftsolutions.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:DataGrid visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateColumns="False"
GridLines="None"
ShowFooter="true"
onItemDataBound="DataGrid1_ItemDataBound"
OnItemCommand="DataInsert"
onEditCommand="DataEdit"
onCancelCommand="DataCancel"
onUpdateCommand="DataUpdate">
<AlternatingItemStyle BorderWidth="0px" BorderStyle="None"
BorderColor="White" BackColor="linen"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" BackColor="#6699cc"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Answer">
<ItemTemplate>
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAnswerFooter" runat="server"></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:textbox>
</EditItemTemplate>
</asp:templateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblPositionID" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.PositionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblPositionIDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblQuestionUnique" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.QuestionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblQuestionUniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="AnswerUnique" visible="false" ReadOnly="true"
HeaderText="AnswerUnique"></asp:BoundColumn>
<asp:EditCommandColumn EditText="<img src='..\images\Edit.png'border='0'
id='textbox1'>" visible="true"
ButtonType="LinkButton"
UpdateText="<img src='..\images\update.png' border='0'>"
CancelText="<img src='..\images\Cancel.png' border='0'>" />
<asp:TemplateColumn >
<FooterTemplate>
<asp:LinkButton CommandName="Insert" Text="<img
src='..\images\Add.gif'border='0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton CommandName="Delete" Text="<img
src='..\images\Delete.gif'border='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</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.FindControl("DataGrid1"),DataGrid)

How would I use oGrid to find and set "lblPositionIDFooter" and
"lblQuestionUniqueFooter"?

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********@gmail.com> wrote in message
news:39****************************@phx.gbl...
Try: e.Item.FindControl("lblPositionIDFooter)
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.FindControl("lblPositionIDFooter")

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

Source Error:

Line 225: Dim oCollapse as ImageButton =
CType(DataList1.Items(DataList1.SelectedIndex).Fin dControl("CollapseButton")
,ImageButton)
Line 226:
Line 227: Dim fPositionID as Label =
oGrid.Item.FindControl("lblPositionIDFooter")
************************************************** ***************

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:DataGrid visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateColumns="False"
GridLines="None"
ShowFooter="true"
onItemDataBound="DataGrid1_ItemDataBound"
OnItemCommand="DataInsert"
onEditCommand="DataEdit"
onCancelCommand="DataCancel"
onUpdateCommand="DataUpdate">
<AlternatingItemStyle BorderWidth="0px"

BorderStyle="None"
BorderColor="White"

BackColor="linen"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True"

BackColor="#6699cc"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Answer">
<ItemTemplate>
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAnswerFooter"

runat="server"></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:textbox>
</EditItemTemplate>
</asp:templateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblPositionID" runat="server" Text='<%

#
DataBinder.Eval(Container, "DataItem.PositionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblPositionIDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblQuestionUnique" runat="server"

Text='<%#
DataBinder.Eval(Container, "DataItem.QuestionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblQuestionUniqueFooter"

runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="AnswerUnique"

visible="false" ReadOnly="true"
HeaderText="AnswerUnique"></asp:BoundColumn>
<asp:EditCommandColumn EditText="<img

src='..\images\Edit.png'border='0'
id='textbox1'>" visible="true"
ButtonType="LinkButton"
UpdateText="<img src='..\images\update.png'

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

border='0'>" />
<asp:TemplateColumn >
<FooterTemplate>
<asp:LinkButton CommandName="Insert" Text="<img
src='..\images\Add.gif'border='0'>" ID="btnAdd"

Runat="server" />
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton CommandName="Delete" Text="<img
src='..\images\Delete.gif'border='0'>" ID="btnDel"

Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</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.FindControl

("DataGrid1"),DataGrid)

How would I use oGrid to find and

set "lblPositionIDFooter" and
"lblQuestionUniqueFooter"?

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.co.in> wrote in message
news:yD****************@news.cpqcorp.net...
First you need to check whether that datagrid item is footer, then you can
use e.item.cells(<correspondingcell index>.findcontrol(<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**********@ftsolutions.com> wrote in message
news:OU**************@TK2MSFTNGP09.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"
AutoGenerateColumns="False"
GridLines="None"
ShowFooter="true"
onItemDataBound="DataGrid1_ItemDataBound"
OnItemCommand="DataInsert"
onEditCommand="DataEdit"
onCancelCommand="DataCancel"
onUpdateCommand="DataUpdate">
<AlternatingItemStyle BorderWidth="0px" BorderStyle="None"
BorderColor="White" BackColor="linen"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" BackColor="#6699cc"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Answer">
<ItemTemplate>
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAnswerFooter" runat="server"></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:textbox>
</EditItemTemplate>
</asp:templateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblPositionID" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.PositionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblPositionIDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblQuestionUnique" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.QuestionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblQuestionUniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="AnswerUnique" visible="false" ReadOnly="true"
HeaderText="AnswerUnique"></asp:BoundColumn>
<asp:EditCommandColumn EditText="<img

src='..\images\Edit.png'border='0' id='textbox1'>" visible="true"
ButtonType="LinkButton"
UpdateText="<img src='..\images\update.png' border='0'>"
CancelText="<img src='..\images\Cancel.png' border='0'>" />
<asp:TemplateColumn >
<FooterTemplate>
<asp:LinkButton CommandName="Insert" Text="<img
src='..\images\Add.gif'border='0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton CommandName="Delete" Text="<img
src='..\images\Delete.gif'border='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</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.FindControl("DataGrid1"),DataGrid)
How would I use oGrid to find and set "lblPositionIDFooter" and
"lblQuestionUniqueFooter"?

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.com...
Hi tshad:

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

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 OnSelectIndexChanged(sender as Object,e as DataListCommandEventArgs)
if e.CommandName = "Select" then
DataList1.SelectedIndex = e.Item.ItemIndex
end if

Dim oGrid as DataGrid =
CType(DataList1.Items(DataList1.SelectedIndex).Fin dControl("DataGrid1"),Data
Grid)

Dim lblPositionIDF as Label =
oGrid.Controls(0).Controls(0).FindControl("lblPosi tionIDFooter")
************************************************** ********************

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:TemplateColumn visible="true">
<ItemTemplate>
<asp:Label id="lblPositionID" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.PositionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblPositionIDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
************************************************** ********************

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**********@ftsolutions.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:DataGrid visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateColumns="False"
GridLines="None"
ShowFooter="true"
onItemDataBound="DataGrid1_ItemDataBound"
OnItemCommand="DataInsert"
onEditCommand="DataEdit"
onCancelCommand="DataCancel"
onUpdateCommand="DataUpdate">
<AlternatingItemStyle BorderWidth="0px" BorderStyle="None"
BorderColor="White" BackColor="linen"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" BackColor="#6699cc"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Answer">
<ItemTemplate>
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAnswerFooter" runat="server"></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:textbox>
</EditItemTemplate>
</asp:templateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblPositionID" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.PositionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblPositionIDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblQuestionUnique" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.QuestionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblQuestionUniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="AnswerUnique" visible="false" ReadOnly="true"HeaderText="AnswerUnique"></asp:BoundColumn>
<asp:EditCommandColumn EditText="<img src='..\images\Edit.png'border='0'id='textbox1'>" visible="true"
ButtonType="LinkButton"
UpdateText="<img src='..\images\update.png' border='0'>"
CancelText="<img src='..\images\Cancel.png' border='0'>" />
<asp:TemplateColumn >
<FooterTemplate>
<asp:LinkButton CommandName="Insert" Text="<img
src='..\images\Add.gif'border='0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton CommandName="Delete" Text="<img
src='..\images\Delete.gif'border='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</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.FindControl("DataGrid1"),DataGrid)
How would I use oGrid to find and set "lblPositionIDFooter" and
"lblQuestionUniqueFooter"?

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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnTest.Click

Dim strText As String

For Each item As DataGridItem In DataGrid1.Items

Dim dgTemp As DataGrid = CType(item.FindControl("DataGrid_PTD"),
DataGrid)
Dim txt As TextBox =
CType(dgTemp.Controls(0).Controls(1).FindControl(" txtPTDsNarrativeAdd"),
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.com...
Hi tshad:

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

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 OnSelectIndexChanged(sender as Object,e as DataListCommandEventArgs)
if e.CommandName = "Select" then
DataList1.SelectedIndex = e.Item.ItemIndex
end if

Dim oGrid as DataGrid =
CType(DataList1.Items(DataList1.SelectedIndex).Fin dControl("DataGrid1"),Data
Grid)

Dim lblPositionIDF as Label =
oGrid.Controls(0).Controls(0).FindControl("lblPosi tionIDFooter")
************************************************** ********************

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:TemplateColumn visible="true">
<ItemTemplate>
<asp:Label id="lblPositionID" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.PositionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblPositionIDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
************************************************** ********************

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**********@ftsolutions.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:DataGrid visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateColumns="False"
GridLines="None"
ShowFooter="true"
onItemDataBound="DataGrid1_ItemDataBound"
OnItemCommand="DataInsert"
onEditCommand="DataEdit"
onCancelCommand="DataCancel"
onUpdateCommand="DataUpdate">
<AlternatingItemStyle BorderWidth="0px" BorderStyle="None"
BorderColor="White" BackColor="linen"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" BackColor="#6699cc"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Answer">
<ItemTemplate>
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAnswerFooter" runat="server"></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:textbox>
</EditItemTemplate>
</asp:templateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblPositionID" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.PositionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblPositionIDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblQuestionUnique" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.QuestionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblQuestionUniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="AnswerUnique" visible="false" ReadOnly="true"HeaderText="AnswerUnique"></asp:BoundColumn>
<asp:EditCommandColumn EditText="<img src='..\images\Edit.png'border='0'id='textbox1'>" visible="true"
ButtonType="LinkButton"
UpdateText="<img src='..\images\update.png' border='0'>"
CancelText="<img src='..\images\Cancel.png' border='0'>" />
<asp:TemplateColumn >
<FooterTemplate>
<asp:LinkButton CommandName="Insert" Text="<img
src='..\images\Add.gif'border='0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton CommandName="Delete" Text="<img
src='..\images\Delete.gif'border='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</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.FindControl("DataGrid1"),DataGrid)
How would I use oGrid to find and set "lblPositionIDFooter" and
"lblQuestionUniqueFooter"?

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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnTest.Click

Dim strNarrativePTD As String
Dim strNarrativeYTD As String
Dim intFooterPTD As Integer
Dim intFooterYTD As Integer
Dim intNarrativeType 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.FindControl("DataGrid_PTD"),
DataGrid)
Dim dgYTD As DataGrid = CType(item.FindControl("DataGrid_YTD"),
DataGrid)

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

'First check the PTD Comments
Dim txtPTD As TextBox =
CType(dgPTD.Controls(0).Controls(intFooterPTD).Fin dControl("txtPTDsNarrativeAdd"), TextBox)
Dim lblPTD As Label =
CType(dgPTD.Controls(0).Controls(intFooterPTD).Fin dControl("lblhAcctPTDAdd"),
Label)
If txtPTD Is Nothing Then
strNarrativePTD = ""
Else
strNarrativePTD = txtPTD.Text
strHAcct = lblPTD.Text
intNarrativeType = 1
End If

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

'Second check the YTD Comments
Dim txtYTD As TextBox =
CType(dgYTD.Controls(0).Controls(intFooterYTD).Fin dControl("txtYTDsNarrativeAdd"), TextBox)
Dim lblYTD As Label =
CType(dgYTD.Controls(0).Controls(intFooterYTD).Fin dControl("lblhAcctYTDAdd"),
Label)
If txtYTD Is Nothing Then
strNarrativeYTD = ""
Else
strNarrativeYTD = txtYTD.Text
strHAcct = lblYTD.Text
intNarrativeType = 12
End If

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

Next

LoadGrid()

End Sub

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

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

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 OnSelectIndexChanged(sender as Object,e as DataListCommandEventArgs)
if e.CommandName = "Select" then
DataList1.SelectedIndex = e.Item.ItemIndex
end if

Dim oGrid as DataGrid =
CType(DataList1.Items(DataList1.SelectedIndex).Fin dControl("DataGrid1"),Data
Grid)

Dim lblPositionIDF as Label =
oGrid.Controls(0).Controls(0).FindControl("lblPosi tionIDFooter")
************************************************** ********************

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:TemplateColumn visible="true">
<ItemTemplate>
<asp:Label id="lblPositionID" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.PositionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblPositionIDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
************************************************** ********************

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**********@ftsolutions.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:DataGrid visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
Height="79px"
AutoGenerateColumns="False"
GridLines="None"
ShowFooter="true"
onItemDataBound="DataGrid1_ItemDataBound"
OnItemCommand="DataInsert"
onEditCommand="DataEdit"
onCancelCommand="DataCancel"
onUpdateCommand="DataUpdate">
<AlternatingItemStyle BorderWidth="0px" BorderStyle="None"
BorderColor="White" BackColor="linen"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" BackColor="#6699cc"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Answer">
<ItemTemplate>
<asp:Label id="lblAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAnswerFooter" runat="server"></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:textbox id="txtAnswer" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Answer") %>'>
</asp:textbox>
</EditItemTemplate>
</asp:templateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblPositionID" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.PositionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblPositionIDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label id="lblQuestionUnique" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.QuestionUnique") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblQuestionUniqueFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="AnswerUnique" visible="false" ReadOnly="true"HeaderText="AnswerUnique"></asp:BoundColumn>
<asp:EditCommandColumn EditText="<img src='..\images\Edit.png'border='0'id='textbox1'>" visible="true"
ButtonType="LinkButton"
UpdateText="<img src='..\images\update.png' border='0'>"
CancelText="<img src='..\images\Cancel.png' border='0'>" />
<asp:TemplateColumn >
<FooterTemplate>
<asp:LinkButton CommandName="Insert" Text="<img
src='..\images\Add.gif'border='0'>" ID="btnAdd" Runat="server" />
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton CommandName="Delete" Text="<img
src='..\images\Delete.gif'border='0'>" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</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.FindControl("DataGrid1"),DataGrid)
How would I use oGrid to find and set "lblPositionIDFooter" and
"lblQuestionUniqueFooter"?

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*******@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnTest.Click

Dim strNarrativePTD As String
Dim strNarrativeYTD As String
Dim intFooterPTD As Integer
Dim intFooterYTD As Integer
Dim intNarrativeType 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.FindControl("DataGrid_PTD"),
DataGrid)
Dim dgYTD As DataGrid = CType(item.FindControl("DataGrid_YTD"),
DataGrid)

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

'First check the PTD Comments
Dim txtPTD As TextBox =
CType(dgPTD.Controls(0).Controls(intFooterPTD).Fin dControl("txtPTDsNarrativeAdd"),
TextBox)
Dim lblPTD As Label =
CType(dgPTD.Controls(0).Controls(intFooterPTD).Fin dControl("lblhAcctPTDAdd"),
Label)
If txtPTD Is Nothing Then
strNarrativePTD = ""
Else
strNarrativePTD = txtPTD.Text
strHAcct = lblPTD.Text
intNarrativeType = 1
End If

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

'Second check the YTD Comments
Dim txtYTD As TextBox =
CType(dgYTD.Controls(0).Controls(intFooterYTD).Fin dControl("txtYTDsNarrativeAdd"),
TextBox)
Dim lblYTD As Label =
CType(dgYTD.Controls(0).Controls(intFooterYTD).Fin dControl("lblhAcctYTDAdd"),
Label)
If txtYTD Is Nothing Then
strNarrativeYTD = ""
Else
strNarrativeYTD = txtYTD.Text
strHAcct = lblYTD.Text
intNarrativeType = 12
End If

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

Next

LoadGrid()

End Sub

"tshad" wrote:
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:og********************************@4ax.com...
> Hi tshad:
>
> You might want to try during the ItemDataBound event instead (check
> for e.Item.ItemType == ListItemType.Footer).
>
> 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 OnSelectIndexChanged(sender as Object,e as DataListCommandEventArgs)
if e.CommandName = "Select" then
DataList1.SelectedIndex = e.Item.ItemIndex
end if

Dim oGrid as DataGrid =
CType(DataList1.Items(DataList1.SelectedIndex).Fin dControl("DataGrid1"),Data
Grid)

Dim lblPositionIDF as Label =
oGrid.Controls(0).Controls(0).FindControl("lblPosi tionIDFooter")
************************************************** ********************

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:TemplateColumn visible="true">
<ItemTemplate>
<asp:Label id="lblPositionID" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.PositionID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label id="lblPositionIDFooter" runat="server">
</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
************************************************** ********************

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**********@ftsolutions.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:DataGrid visible="False"
> > border=1
> > id="DataGrid1"
> > runat="server"
> > Width="400px"
> > Height="79px"
> > AutoGenerateColumns="False"
> > GridLines="None"
> > ShowFooter="true"
> > onItemDataBound="DataGrid1_ItemDataBound"
> > OnItemCommand="DataInsert"
> > onEditCommand="DataEdit"
> > onCancelCommand="DataCancel"
> > onUpdateCommand="DataUpdate">
> > <AlternatingItemStyle BorderWidth="0px" BorderStyle="None"
> >BorderColor="White" BackColor="linen"></AlternatingItemStyle>
> > <HeaderStyle Font-Bold="True" BackColor="#6699cc"></HeaderStyle>
> > <Columns>
> > <asp:TemplateColumn HeaderText="Answer">
> > <ItemTemplate>
> > <asp:Label id="lblAnswer" runat="server" Text='<%#
> >DataBinder.Eval(Container, "DataItem.Answer") %>'>
> > </asp:Label>
> > </ItemTemplate>
> > <FooterTemplate>
> > <asp:TextBox id="txtAnswerFooter" runat="server"></asp:TextBox>
> > </FooterTemplate>
> > <EditItemTemplate>
> > <asp:textbox id="txtAnswer" runat="server" Text='<%#
> >DataBinder.Eval(Container, "DataItem.Answer") %>'>
> > </asp:textbox>
> > </EditItemTemplate>
> > </asp:templateColumn>
> > <asp:TemplateColumn >
> > <ItemTemplate>
> > <asp:Label id="lblPositionID" runat="server" Text='<%#
> >DataBinder.Eval(Container, "DataItem.PositionID") %>'>
> > </asp:Label>
> > </ItemTemplate>
> > <FooterTemplate>
> > <asp:Label id="lblPositionIDFooter" runat="server">
> > </asp:Label>
> > </FooterTemplate>
> > </asp:TemplateColumn>
> > <asp:TemplateColumn >
> > <ItemTemplate>
> > <asp:Label id="lblQuestionUnique" runat="server" Text='<%#
> >DataBinder.Eval(Container, "DataItem.QuestionUnique") %>'>
> > </asp:Label>
> > </ItemTemplate>
> > <FooterTemplate>
> > <asp:Label id="lblQuestionUniqueFooter" runat="server">
> > </asp:Label>
> > </FooterTemplate>
> > </asp:TemplateColumn>
> > <asp:BoundColumn DataField="AnswerUnique" visible="false"

ReadOnly="true"
> >HeaderText="AnswerUnique"></asp:BoundColumn>
> > <asp:EditCommandColumn EditText="<img

src='..\images\Edit.png'border='0'
> >id='textbox1'>" visible="true"
> > ButtonType="LinkButton"
> > UpdateText="<img src='..\images\update.png' border='0'>"
> >CancelText="<img src='..\images\Cancel.png' border='0'>" />
> > <asp:TemplateColumn >
> > <FooterTemplate>
> > <asp:LinkButton CommandName="Insert" Text="<img
> >src='..\images\Add.gif'border='0'>" ID="btnAdd" Runat="server" />
> > </FooterTemplate>
> > <ItemTemplate>
> > <asp:LinkButton CommandName="Delete" Text="<img
> >src='..\images\Delete.gif'border='0'>" ID="btnDel" Runat="server" />
> > </ItemTemplate>
> > </asp:TemplateColumn>
> > </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.FindControl("DataGrid1"),DataGrid)
> >
> >How would I use oGrid to find and set "lblPositionIDFooter" and
> >"lblQuestionUniqueFooter"?
> >
> >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
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. ...
0
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...
2
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...
2
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....
3
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...
4
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...
2
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...
1
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...
3
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.