473,854 Members | 1,807 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 1670
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
9363
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
1463
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
2769
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
958
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
1600
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
7864
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
1803
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
2725
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
9819
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
11024
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10740
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
9510
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
7909
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
5738
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
5937
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4550
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
2
4149
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3182
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.