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, the 1st columnt is showing FooterText = "Select". I need to be able to click this column (same way I do in the GridView.Data) and in my code behing capture this click event.
Mark Up Code:
Code Behind:Code:<asp:GridView ID="GridView1" runat="server" Style="z-index: 102; left: 0px; position: relative; top: 43px; border-right: gray thin solid; border-top: gray thin solid; border-left: gray thin solid; border-bottom: gray thin solid; font-size: 12px; overflow: hidden; clip: rect(auto auto auto auto);" Width="342px" AllowPaging="True" AllowSorting="True" Font-Size="Small" AutoGenerateColumns="False" CellSpacing="2" HorizontalAlign="Left" BorderColor="LightGray" BorderStyle="None" PageSize="14" OnSorting="GridView1_Sorting" OnRowCommand="GridView1_RowCommand" EmptyDataText="No records found" ShowFooter="True"> <Columns> <asp:CommandField HeaderText="Detail" ShowSelectButton="True" FooterText="Select"> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" Width="10px" /> </asp:CommandField> <asp:BoundField DataField="equipmentID" HeaderText="Equipment ID" SortExpression="equipmentID"> <ItemStyle HorizontalAlign="Left" Width="60px" /> <HeaderStyle HorizontalAlign="Center" /> </asp:BoundField> <asp:BoundField DataField="equipmentname" HeaderText="Equipment Name" FooterText="Total"> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Left" Width="240px" /> <FooterStyle HorizontalAlign="Right" /> </asp:BoundField> <asp:BoundField DataField="hours" HeaderText="Hours" NullDisplayText="0"> <ItemStyle HorizontalAlign="Right" Width="80px" /> <FooterStyle HorizontalAlign="Right" /> </asp:BoundField> </Columns> <HeaderStyle BackColor="#FFC080" Height="35px" /> <AlternatingRowStyle BackColor="#FFFFC0" /> <SelectedRowStyle BackColor="#FF8080" /> <EditRowStyle BackColor="#FF8080" /> <RowStyle Height="20px" /> <FooterStyle BackColor="#FF8080" /> </asp:GridView>
Code:Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound Dim tabledata As Data.DataRowView = e.Row.DataItem If e.Row.RowType = DataControlRowType.Footer Then e.Row.Cells(0).Text = "Select" e.Row.Cells(2).Text = "Selection Total" e.Row.Cells(3).Text = Session("TotalHours") End If End Sub




Reply With Quote