Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 20th, 2009, 03:39 PM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Question GridView Footer - need help

I have an application where user is able to select jobs which will show equipment ID and equipment hours.

I am displaying a GridView that has a CommandField in the 1st column with a ShowSelectButton= True. The user is able to click the select button and a 2nd (detailed) GridView is shown. This works fine.

I have added a Footer to my GridView. I show total equipment hours for the selection (looping through the Data Table). This work fine as well.

Now. I would like to be able to have a ShowSelectButton on the Footer as well, let user be able to click and then call a stored procedure. Is this possible. I have tried to add an attribute to the footer cell but not be able to get it working

Code:
 
If e.Row.RowType = DataControlRowType.Footer Then
e.Row.Cells(0).Text = "Select"
e.Row.Cells(0).Attributes.Add ---> onclick ?
e.Row.Cells(2).Text = "Selection Total"
e.Row.Cells(3).Text = Session("TotalHours")
EndIf

Last edited by snufse; May 21st, 2009 at 08:30 AM..
 
Old May 21st, 2009, 08:58 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default

II managed to add a link button to my gridview footer like this:

Code:
 
ProtectedSub GridView1_RowDataBound(ByVal sender AsObject, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim tabledata As Data.DataRowView = e.Row.DataItem
If e.Row.RowType = DataControlRowType.Footer Then
myLinkButton.Text = "Select"
myLinkButton.CommandName = "SelectFooter"
AddHandler myLinkButton.Click, New EventHandler(AddressOf ClickHandler)
e.Row.Cells(0).Controls.Add(myLinkButton)
e.Row.Cells(2).Text = "Selection Total"
e.Row.Cells(3).Text = Session("TotalHours")
EndIf
EndSub
Now my next question is how do I capture the "click" event? I tried this but does not work:


Code:
 
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
If e.CommandName = "Select" Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim mySelectedRow As GridViewRow = GridView1.Rows(index)
Dim mySelectedCell As TableCell
mySelectedCell = mySelectedRow.Cells(1)
Equipment_ID = mySelectedCell.Text.ToString
GetItemDetail(Equipment_ID)
DisplayItemDetail()
End If
If e.CommandName = "SelectFooter" Then
AddHandler myLinkButton.Click, New EventHandler(AddressOf ClickHandler)
End If
End Sub
 
 
Public Sub ClickHandler(ByVal sender As Object, ByVal e As EventArgs)
'Handle LinkButton click event here. But this event never gets called...
End Sub

Last edited by snufse; May 21st, 2009 at 10:15 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
user control javascript not working in footer row of a gridview gagansharma7 ASP.NET 2.0 Professional 5 May 7th, 2009 04:33 PM
problem in displaying null value to the control in the footer template of gridview jazzydonald ASP.NET 3.5 Basics 14 February 16th, 2009 09:33 AM
Totaling columns in a footer row of a GridView psimonson ASP.NET 2.0 Basics 1 May 5th, 2008 01:34 PM
Disp Footer even no record in GridView Datasource mallikalapati ASP.NET 2.0 Professional 1 March 19th, 2008 02:23 AM
display sum in footer of gridview sarah lee ASP.NET 1.0 and 1.1 Basics 3 December 27th, 2006 12:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.