473,387 Members | 1,515 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,387 software developers and data experts.

Retrieving a literal value from a datagrid footer

BACKGROUND:
I have a bound datagrid with the following code -

<asp:datagrid id="dgla" OnItemCommand="declareDatagrid">
....
<Columns>
<ItemTemplate>
<asp:Literal id="lbOnLoan" Runat="server" />
</ItemTemplate>
<FooterTemplate>
<asp:Literal ID="lbTotalOnLoan" Runat="server" />
</FooterTemplate>
</columns>
</datagrid>

In the code behind I set the value of Literal.text when the datagrid is
bound.

On the same page that the datagrid is displayed I have a button that
when clicked sends an email - I have no problem coding the email
controls.

THE PROBLEM:
As part of the text of this email I want to include the VALUE that is
held the Literal.Text and I can't seem to extract it.

I think the solution is based on FINDCONTROL but I know that I am doing
something wrong.

Any solutions would be greatly appreciated.

Nov 19 '05 #1
4 2196
You have to use FindControl on the last element in the DataGrid
object's Controls array.

Example: http://odetocode.com/Articles/116.aspx

HTH,

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

On 20 May 2005 07:08:31 -0700, na************@burohappold.com wrote:
BACKGROUND:
I have a bound datagrid with the following code -

<asp:datagrid id="dgla" OnItemCommand="declareDatagrid">
...
<Columns>
<ItemTemplate>
<asp:Literal id="lbOnLoan" Runat="server" />
</ItemTemplate>
<FooterTemplate>
<asp:Literal ID="lbTotalOnLoan" Runat="server" />
</FooterTemplate>
</columns>
</datagrid>

In the code behind I set the value of Literal.text when the datagrid is
bound.

On the same page that the datagrid is displayed I have a button that
when clicked sends an email - I have no problem coding the email
controls.

THE PROBLEM:
As part of the text of this email I want to include the VALUE that is
held the Literal.Text and I can't seem to extract it.

I think the solution is based on FINDCONTROL but I know that I am doing
something wrong.

Any solutions would be greatly appreciated.


Nov 19 '05 #2
Thanks Scott, very useful and very much appreciated.

The code (VB.NET) solution you led me to was as follows -

Dim txt As Literal
Dim footerIndex As Integer

footerIndex = CType(dgla.Controls(0).Controls.Count - 1, Integer)
txt =
CType(dgla.Controls(0).Controls(footerIndex).FindC ontrol("lbTotalcopiesHeld"),
Literal)
Response.Write(txt.Text)

As you can see from my first meassage:
dgla - is my is my datagrid id
lbTotalcopiesHeld - the literal id where the value is held

I hope others find this solution useful.

Nov 19 '05 #3
Thanks Scott very useful and very much appreciated

The solution you led me to use (VB.NET) was -

Dim lit1 As Literal
Dim footerIndex1 As Integer

footerIndex1 = CType(dgla.Controls(0).Controls.Count - 1, Integer)
lit1 =
CType(dgla.Controls(0).Controls(footerIndex1).Find Control("lbTotalOnLoan"),
Literal)

response.write(lit1.Text)

Where 'dgla' is my Datagrid ID,, and 'lbTotalOnLoan' is the ID of the
Literal contained in the footer that holds the value I was trying to
extract.

I hope others find this simple solution useful.

Nov 19 '05 #4
Very cool, I'm glad to be of assistance.

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

On 20 May 2005 09:14:21 -0700, na************@burohappold.com wrote:
Thanks Scott very useful and very much appreciated

The solution you led me to use (VB.NET) was -

Dim lit1 As Literal
Dim footerIndex1 As Integer

footerIndex1 = CType(dgla.Controls(0).Controls.Count - 1, Integer)
lit1 =
CType(dgla.Controls(0).Controls(footerIndex1).Fin dControl("lbTotalOnLoan"),
Literal)

response.write(lit1.Text)

Where 'dgla' is my Datagrid ID,, and 'lbTotalOnLoan' is the ID of the
Literal contained in the footer that holds the value I was trying to
extract.

I hope others find this simple solution useful.


Nov 19 '05 #5

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

Similar topics

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: Steve | last post by:
I'm in a weird situation where I'm using ComboBox's in a DataGrid. When the ComboBox selection changes, I'm currently storing the SelectedValue object into the DataSource of the DataGrid cell. ...
4
by: Jim Heavey | last post by:
Suppose I am using a series of controls in the footer of a datagrid which allows a user to enter "a new row of information to be added to the datagrid datasource". Some of these controls have a...
3
by: Mau | last post by:
I have a question: I have a datagrid with paging (4 elements for page), header and footer I set a fixed height: 600px So the situation is (in a page with 5 elements) 6 rows (header + 4...
9
by: tshad | last post by:
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: ...
6
by: Jenna Alten | last post by:
I have a datagrid with a template column that contains a dropdown list. I currently fill and display the dropdown list on the page load. This is working correctly. I am NOT using an Edit Column. I...
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...
0
by: jason | last post by:
Hello everyone. I am trying to write some custom command events into a DataGrid. The command that is currently giving me trouble is an "Add" custom command in the footer of a template column. ...
6
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.