473,785 Members | 2,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview Footer Help

I reviewed a couple of tutorials that show how to display totals in
the footer of a gridview. My footer shows up blank. Can someone help
me. The code is as follows:

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<script runat="server">
Dim weighttotal As Decimal = 0
'Dim quantityTotal As Integer = 0
Sub detailsGridView _RowDataBound(B yVal sender As Object, _
ByVal e As GridViewRowEven tArgs)
If e.Row.RowType = DataControlRowT ype.DataRow Then
' add the UnitPrice and QuantityTotal to the running total
variables
weighttotal +=
Convert.ToDecim al(DataBinder.E val(e.Row.DataI tem, _
"scale1"))
ElseIf e.Row.RowType = DataControlRowT ype.Footer Then
e.Row.Cells(1). Text = "Totals:"
e.Row.Cells(2). Text = weighttotal.ToS tring()

e.Row.Cells(1). HorizontalAlign = HorizontalAlign .Right
e.Row.Cells(2). HorizontalAlign = HorizontalAlign .Right
e.Row.Font.Bold = True
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateCol umns="False" DataKeyNames="I D"
showfooter=true
DataSourceID="A ccessDataSource 1" Style="z-index: 100;
left: 88px; position: absolute;
top: 115px">
<Columns>
<asp:BoundFie ld DataField="ID" HeaderText="ID"
InsertVisible=" False" ReadOnly="True"
SortExpression= "ID" />
<asp:BoundFie ld DataField="Scal e1" HeaderText="Sca le1"
SortExpression= "Scale1" />
<asp:BoundFie ld DataField="Scal e2" HeaderText="Sca le2"
SortExpression= "Scale2" />
<asp:BoundFie ld DataField="Empl oyee"
HeaderText="Emp loyee" SortExpression= "Employee" />
</Columns>
</asp:GridView>
<asp:AccessData Source ID="AccessDataS ource1" runat="server"
DataFile="~/App_Data/Spare_Parts_II_ BCPC.mdb"
SelectCommand=" SELECT * FROM [Scrap]"></
asp:AccessDataS ource>

</div>
</form>
</body>
</html>
Jun 27 '08 #1
1 1665
I think your problem is trying to access cells in the foota when there isn't
any.
Put a table in the foota and use find control to access it
here is a example using a repeater

If e.Item.ItemType = ListItemType.Fo oter Then
Dim footaTab As Table = e.Item.FindCont rol("Table1")
Dim tc As TableCell = New TableCell
tc.Text = "5555"
footaTab.Rows(0 ).Cells.Add(tc)
End If



"Michael" <bg********@gma il.comwrote in message
news:89******** *************** ***********@59g 2000hsb.googleg roups.com...
>I reviewed a couple of tutorials that show how to display totals in
the footer of a gridview. My footer shows up blank. Can someone help
me. The code is as follows:

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<script runat="server">
Dim weighttotal As Decimal = 0
'Dim quantityTotal As Integer = 0
Sub detailsGridView _RowDataBound(B yVal sender As Object, _
ByVal e As GridViewRowEven tArgs)
If e.Row.RowType = DataControlRowT ype.DataRow Then
' add the UnitPrice and QuantityTotal to the running total
variables
weighttotal +=
Convert.ToDecim al(DataBinder.E val(e.Row.DataI tem, _
"scale1"))
ElseIf e.Row.RowType = DataControlRowT ype.Footer Then
e.Row.Cells(1). Text = "Totals:"
e.Row.Cells(2). Text = weighttotal.ToS tring()

e.Row.Cells(1). HorizontalAlign = HorizontalAlign .Right
e.Row.Cells(2). HorizontalAlign = HorizontalAlign .Right
e.Row.Font.Bold = True
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateCol umns="False" DataKeyNames="I D"
showfooter=true
DataSourceID="A ccessDataSource 1" Style="z-index: 100;
left: 88px; position: absolute;
top: 115px">
<Columns>
<asp:BoundFie ld DataField="ID" HeaderText="ID"
InsertVisible=" False" ReadOnly="True"
SortExpression= "ID" />
<asp:BoundFie ld DataField="Scal e1" HeaderText="Sca le1"
SortExpression= "Scale1" />
<asp:BoundFie ld DataField="Scal e2" HeaderText="Sca le2"
SortExpression= "Scale2" />
<asp:BoundFie ld DataField="Empl oyee"
HeaderText="Emp loyee" SortExpression= "Employee" />
</Columns>
</asp:GridView>
<asp:AccessData Source ID="AccessDataS ource1" runat="server"
DataFile="~/App_Data/Spare_Parts_II_ BCPC.mdb"
SelectCommand=" SELECT * FROM [Scrap]"></
asp:AccessDataS ource>

</div>
</form>
</body>
</html>
Jun 27 '08 #2

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

Similar topics

1
9356
by: Miguel Dias Moura | last post by:
Hello, I have a GridView in my page which is created in runtime. It works fine. My page has 2 Asp Buttons: - The HIDE button makes GridView.Visible = False; - The SHOW button makes GridView.Visible = True. I press HIDE and the GridView disappears as expected. After it I press SHOW and the GridView doesn't show.
0
1456
by: tfsmag | last post by:
I know how to do summary footers in a gridview... but when i try it in a paged gridview it puts a footer on every page of just the items on that page. Any suggestions on how to get it to work so that it only posts on the last page of the gridview with the totals for the entire dataset? here is how i'm getting the footer summary now Protected Sub TotIncurGrid_RowDataBound(ByVal sender As Object, ByVal e As...
2
2762
by: Flinky Wisty Pomm | last post by:
Hi all, I've got a really annoying problem that I need to fix sharpish. I've got a GridView derived control which has a templated header and footer. It works wonderfully on the first render but then the header/footer vanish into thin air. If I add the header/footer onDataBound then they disappear when I do a postback with no databinding. If I add them during PreRender, then they persist, but one of my data rows is emptied for each time I...
0
954
by: yossimotro | last post by:
Hi, I'm using a gridview in my project and its footer to add new records. The gridview is connected to an AccessDataSource which contains select, insert and delete commands. The problem occurs when the AccessDataSource is empty, the gridview won't show at all, not even the footer so I can't add new data. I know I can give up on the footer and just create somelike myself
0
1597
by: luvdairish | last post by:
Controls (in order on page) 1.)GridView - each row is a work order w/ a link for details in the last column 2.)DetailsView - when user clicks on link from above GridView, the details are shown 3.)GridView - nested in the footer of the above DetailsView. each row is a person assigned to that work order 4.)DetailsView - only visible when the user clicks "add tech" in the DetailsView from #2 (above). allows technician to be added to work...
0
7861
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have to display total time in the footer of my gridview so I have a columnn a. I followed micrososft example to create the footer and display the total time and it is not displaying anything in the footer of the gridview. Below is my code colA
0
1798
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have a gridview. I calculated some values in the gridview for the footer of the gridview so basically I am adding all the values that are displayed in the gridview for each column and displaying the total in the footer of the gridview. Now I export the gridview to excel spreadsheet with the code below. Everything is exported well except the footer value become zero in the excel spreadsheet. Can anyone tell me how can i...
0
2717
by: gnewsgroup | last post by:
Well, I am trying to use the footer row of a GridView for insertion purpose. There are some articles about this, for example, the gridviewguy.com has an example, which always displays the footer row. I would like to display the footer row, only when a LinkButton "Add New" is clicked. And after the new record is saved to the database, let the footer row disappear. In the LinkButton's click event handler, I simply say:
3
9817
by: tshad | last post by:
I am building a GridView that is displaying some money values in 3 columns. I want to put the totals of each column in a label field (one for each column) in the footer. I was trying to figure out which was the faster way or more efficient way. I originally thought about getting SQL to do it, but that would entail either a second Select or some type of subquery or self join, which I am not sure is the best way.
0
9643
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...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10085
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
8968
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
7494
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
6737
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
5379
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...
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.