Closed Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 14 of 14

Thread: add additional footer to gridview

  1. #11
    Barn Enthusiast peebman2000 is on a distinguished road peebman2000's Avatar
    Join Date
    Mar 2008
    Posts
    215
    Rep Power
    4

    reply

    Okay that worked, thanks. Now I need to add the second footer for the percentages. Now I already have the code to calculate the percentages, but how to do I add the additional footer.

    Do I use the alternatignitemtemplate as the additional footer or do I use the separatortemplate as the additonal footer?

    Let me know thanks.

    aspx page:
    Code:
    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
            <HeaderTemplate>
                    <table border=1>
                      <tr>
                        <td><b>Received</b></td>
                        <td><b>Answars</b></td>
                        <td><b>Product</b></td>
                      </tr>
    
            </HeaderTemplate>
            <ItemTemplate>
            <tr>
                      <td> <%#DataBinder.Eval(Container.DataItem, "received")%> </td>
                      <td> <%#DataBinder.Eval(Container.DataItem, "ansers")%> </td>
                      <td> <%# DataBinder.Eval(Container.DataItem, "product") %> </td>
                    </tr>
    
                
                
            </ItemTemplate>
            <FooterTemplate>
                    <tr>
                    
                      <td> <asp:Label ID="lblreceieved" runat="server" Text=""></asp:Label> </td>
                      <td> <asp:Label ID="lblansers" runat="server" Text=""></asp:Label> </td>
                      <td> <asp:Label ID="Label1" runat="server" Text="Total"></asp:Label> </td>
                      
                    </tr>
            </FooterTemplate>
            <AlternatingItemTemplate>
            </AlternatingItemTemplate>
            <SeparatorTemplate>
            </SeparatorTemplate>
            </asp:Repeater>
    

    aspx.vb page:
    Code:
    Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
            'Dim total2 As Decimal = 0
    
            'If e.Item.DataItem = DataControlRowType.DataRow Then
            '    Total += GetUnitPrice(Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "received")))
            '    total2 += GetUnitPrice(Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "ansers")))
            'ElseIf e.Item.DataItem = DataControlRowType.Footer Then
    
            '    e.Item.DataItem.cell(0).text = Total.ToString()
            '    e.Item.DataItem.cell(1).text = total2.ToString()
            Dim total2 As Decimal = 0
    
            'If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
            '    Total += GetUnitPrice(Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "received")))
            '    total2 += GetUnitPrice(Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "ansers")))
            If e.Item.ItemType = ListItemType.Footer Then
                Dim lblrec As Label = TryCast(e.Item.FindControl("lblreceieved"), Label)
                lblrec.Text = Repeater1.Items.Count
    
                Dim lblans As Label = TryCast(e.Item.FindControl("lblansers"), Label)
                lblans.Text = Repeater1.Items.Count
    
                'e.Item.DataItem.cell(0).text = Total.ToString()
                'e.Item.DataItem.cell(1).text = total2.ToString()
    
    
    
    
    
            End If
        End Sub
    


    Quote Originally Posted by jmurrayhead View Post
    You will want to check the row type like this in a repeater:

    Code:
    If e.Item.RowType = ListItemType.Item Or e.Item.RowType = ListItemType.AlternatingItem Then
        ....
    ElseIf e.Item.RowType = ListItemType.Footer Then
        ....
    End If
    

  2. #12
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Inside the FooterTemplate...just use the table HTML to create another row. Then place controls in that row and handles data that way
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  3. #13
    Barn Enthusiast peebman2000 is on a distinguished road peebman2000's Avatar
    Join Date
    Mar 2008
    Posts
    215
    Rep Power
    4

    reply

    Cheers dude, that works. I feel like a little kid, i'm glad that works. Now I just have to make sure it exports to an excel spreadsheet.

    I think I can handle that.

    Thanks for the repeater 101 lesson, i actually like the repeater better than the gridview control.

    Anyway thanks again man talk to you later, i appreciate it.

    Quote Originally Posted by jmurrayhead View Post
    Inside the FooterTemplate...just use the table HTML to create another row. Then place controls in that row and handles data that way

  4. #14
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Quote Originally Posted by peebman2000 View Post
    Cheers dude, that works. I feel like a little kid, i'm glad that works. Now I just have to make sure it exports to an excel spreadsheet.

    I think I can handle that.

    Thanks for the repeater 101 lesson, i actually like the repeater better than the gridview control.

    Anyway thanks again man talk to you later, i appreciate it.
    No problem The Repeater is a valuable tool in the .Net ToolBox. I'm sure you'll get plenty of use out of it.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


Closed Thread
Page 2 of 2 FirstFirst 1 2

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO