473,498 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid footer not displaying data

the below itemdatabound function works , displays all the grand totals
in the footer control of the datagrid:

private void dglvboard_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
DataRowView rowData;
decimal price;
decimal priceWk;
decimal newssum;
decimal newssumWk;
System.Web.UI.WebControls.Literal Amount_RevenueLabel = null;
System.Web.UI.WebControls.Literal Amount_RevenueLabelWk = null;
System.Web.UI.WebControls.Literal NewsLabel = null;
System.Web.UI.WebControls.Literal NewsLabelWk = null;
/System.Web.UI.WebControls.Literal totalLabel = null;
System.Web.UI.WebControls.Literal totalLabelWk = null;
System.Web.UI.WebControls.Literal newstotalLabel = null;
System.Web.UI.WebControls.Literal newstotalLabelWk = null;
// check the type of item that was databound and only take action if
it
// was a row in the datagrid
switch (e.Item.ItemType)
{
case ListItemType.AlternatingItem:
case ListItemType.EditItem:
case ListItemType.Item:
case ListItemType.SelectedItem:
// get the data for the item being bound
rowData = (DataRowView)(e.Item.DataItem);

// get the value for the list price and add it to the sum
// get the control used to display the list price
// NOTE: This can be done by using the FindControl method of the
// passed item because ItemTemplates were used and the anchor
// controls in the templates where given IDs. If a standard
// BoundColumn was used, the data would have to be accessed
// using the cellscollection (e.g.
e.Item.Cells(1).controls(1)
// would access the label control in this example.

// now format the list price in
currency format

// get the value for the discounted price and add it to the sum

price = System.Convert.ToDecimal(rowData["dbltempTotalVolume"]);
priceWk = System.Convert.ToDecimal(rowData["dblTotalVolumeWk"]);

newssum = DBValueToInt(rowData["news"], 0);
////-//converting news like price et priceWk above
newssum = System.Convert.ToDecimal(rowData["news"]);
newssumWk = System.Convert.ToDecimal(rowData["newsWk"]);

mAmount_RevenueTotal += price/2;
mAmount_RevenueTotalWk += priceWk/2;
mNewsTotal += newssum/2;
mNewsTotalWk += newssumWk/2;
////-///temp test cg from init dblTotalVolume

// get the control used to display the discounted price
Amount_RevenueLabel = (System.Web.UI.WebControls.Literal)
(e.Item.FindControl("lblAmount_Revenue"));
Amount_RevenueLabelWk = (System.Web.UI.WebControls.Literal)
(e.Item.FindControl("lblAmount_RevenueWk"));
NewsLabel = (System.Web.UI.WebControls.Literal)
(e.Item.FindControl("lblNews"));
NewsLabelWk = (System.Web.UI.WebControls.Literal)
(e.Item.FindControl("lblNewsWk"));
// now format the discounted price in currency format
Amount_RevenueLabel.Text = price.ToString("C2");
Amount_RevenueLabelWk.Text = priceWk.ToString("C2");
NewsLabel.Text = newssum.ToString();
NewsLabelWk.Text = newssumWk.ToString();
break;
case ListItemType.Footer:
// get the control used to display the total of the list prices

// prices and set its value to the total of the discounted prices
totalLabel = (System.Web.UI.WebControls.Literal)
(e.Item.FindControl("lblAmount_RevenueTotal"));
totalLabel.Text = mAmount_RevenueTotal.ToString("C2");
totalLabelWk = (System.Web.UI.WebControls.Literal)
(e.Item.FindControl("lblAmount_RevenueTotalWk"));
totalLabelWk.Text = mAmount_RevenueTotalWk.ToString("C2");
newstotalLabel = (System.Web.UI.WebControls.Literal)
(e.Item.FindControl("lblNewsTotal"));
newstotalLabel.Text = mNewsTotal.ToString();

newstotalLabelWk = (System.Web.UI.WebControls.Literal)
(e.Item.FindControl("lblNewsTotalWk"));
newstotalLabelWk.Text = mNewsTotalWk.ToString();
break;
default:
// ListItemType.Header, ListItemType.Pager, or
ListItemType.Separator
// no action required
break;
}

..but the following does not display the grand total in the footer
rows, tho it does display all the other rows
in the datagrid:
//
private void dglvboard_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
switch (e.Item.ItemType)
{
case ListItemType.AlternatingItem:
//e.Item.BackColor = Color.Aqua;
break;
case ListItemType.Footer:
e.Item.Cells[1].Text = mAmount_RevenueTotal.ToString("C2");
e.Item.Cells[1].HorizontalAlign = HorizontalAlign.Right;
e.Item.Cells[2].Text = mAmount_RevenueTotalWk.ToString("C2");
e.Item.Cells[2].HorizontalAlign = HorizontalAlign.Right;
e.Item.Cells[3].Text = mNewsTotal.ToString();
e.Item.Cells[3].HorizontalAlign = HorizontalAlign.Right;
e.Item.Cells[4].Text = mNewsTotalWk.ToString();
e.Item.Cells[4].HorizontalAlign = HorizontalAlign.Right;
break;
}
}

The footer template in these two examples is exactly the same (I'll
show you the one for the amount_revenue total display):
<FooterTemplate>
<asp:Literal id="lblAmount_RevenueTotal" runat="server" />
</FooterTemplate>

..in both cases, the function is drawing data from a datarow that is
configured the same way. But am wondering what i am missing in the
second function example I have listed. I can provide further code
samples as far as how vars are being initialized and called.
??
TIA
.netsports

Mar 13 '06 #1
1 1983
Hi,

I think that your code is not very efficient, updating the total label on
each databound is not very good idea, it's much better to store the running
value in a protected variable and just bind that value in the footer.

You do nt update the total in the second example. unless you miss some code.

Do the above suggestion and all will be easier.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Mar 13 '06 #2

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

Similar topics

3
4854
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
4
1653
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...
2
1212
by: Mervin Williams | last post by:
I just discovered that the datagrid does not display if the webform is in new mode. Let's say, for instance, that my datagrid is for contacts related to a company, so that companyid id a foreign...
9
5037
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: ...
4
1359
by: MrMike | last post by:
Is it possible to specify (or somehow set) the amount of space between each datagrid row without changing the amount of space between datagrid columns? I have a datagrid displaying data which...
4
1636
by: JJ | last post by:
Hi, I am using a datagrid to display employee time sheets and need a running total for datagrid. So I am wondering since I am displaying totals in footer, should I use maybe a new datalist or...
1
1062
by: Adam Knight | last post by:
Hi all, I am using a datagrid footer as a container for some data entry controls. Above the datagrid is another data entry point which needs to be filled out before prior to entering data in...
1
1255
by: .Net Sports | last post by:
the below itemdatabound function works , displays all the grand totals in the footer control of the datagrid: private void dglvboard_ItemDataBound(object sender,...
1
2673
by: rascalking | last post by:
Hello, So I've read many forums that explained how to get an image out of SQL Server database and display it. I used an alternate .aspx page to retrieve the image and write it back as binary...
0
7165
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
7205
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
7379
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
5462
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,...
1
4910
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...
0
4590
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...
0
3093
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...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.