locked
Add a function to filter repeater in columns RRS feed

  • Question

  • User521171331 posted

    Hi, I have created some tables and want to produce a report (attachment 1). But I only able to produce a report (attachment 2). The total qty is actually the total of the four "Balance" column. Actually, I just would like to know how can I call a function in that four column. My idea is to call the function and just pass in the status to the function for me to filter the same query used.

    My aspx code is below:

            <asp:Repeater ID="LV_Report" runat="server">
            <HeaderTemplate>
            <table class="table table-striped" style="width:1600px">
            <tr style="background-color:silver">
                <th class="col-sm-1" rowspan="2">Date</th>
                <th class="col-sm-1" rowspan="2">Desk Order</th>
                <th class="col-sm-1" rowspan="2">Customer Name</th>
                <th class="col-sm-2" rowspan="2">Project Name</th>
                <th class="col-sm-1" rowspan="2">Total Qty</th>
                <th class="col-sm-2 text-center" colspan="4">Balance</th>
            </tr>
            <tr style="background-color:silver">
                <th class="col-sm-1 text-center">DP</th>
                <th class="col-sm-1 text-center">Act</th>
                <th class="col-sm-1 text-center">PB</th>
                <th class="col-sm-1 text-center">GD</th>
            </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                <td><%# Eval("Desk_Order_Date", "{0:dd-MM-yyyy}") %></td>
                <td><%# Eval("Desk_Order_No")%></td>
                <td><%# Eval("Customer_Name")%></td>
                <td><%# Eval("Project_Name")%></td>
                <td><%# Eval("Total_Qty", "{0:0}")%></td>
                <td class="col-sm-1 text-center">120</td>
                <td class="col-sm-1 text-center">150</td>
                <td class="col-sm-1 text-center">200</td>
                <td class="col-sm-1 text-center">202</td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
            </table>
            </FooterTemplate>
            </asp:Repeater>

    My aspx.vb code is below:

        Private Sub LV_Report_Load(sender As Object, e As EventArgs) Handles LV_Report.Load
            If Not IsPostBack Then
                Dim strQuery As String = " select do.Desk_Order_Date, do.Desk_Order_No, c.Customer_Name, p.Project_Name, sum(dod.Order_Quantity) as Total_Qty " _
                    & " from desk_order do " _
                    & " inner join Customer c on do.Customer_ID = c.Customer_ID " _
                    & " inner join project p on do.project_ID = p.project_ID " _
                    & " inner join Desk_Order_Detail dod on do.Desk_Order_ID = dod.Desk_Order_ID " _
                    & " group by do.Desk_Order_Date, do.Desk_Order_No, c.Customer_Name, p.Project_Name "
    
                LV_Report.DataSource = myFunctions.ExeReader(strQuery)
                LV_Report.DataBind()
            End If
        End Sub

    Attachment 1 is below:

    Attachment 2 is below:

    Sunday, January 15, 2017 8:29 AM

All replies

  • User-707554951 posted

    Hi ngaisteve1,

    Do you want to calculate the Qty with that four coloums?

    If that’s your requirement, you could try to use OnItemDataBound.

    For example:

      <form id="form1" runat="server">
            <div>
                <asp:Repeater ID="LV_Report" OnItemDataBound="LV_Report_ItemDataBound"  runat="server">
                   <HeaderTemplate>
                        <table class="table table-striped" style="width: 1600px">
                            <tr style="background-color: silver">
                                <th class="col-sm-1" rowspan="2">ID</th>
                                <th class="col-sm-1" rowspan="2">Total Qty</th>
                                <th class="col-sm-2 text-center" colspan="4">Balance</th>
                            </tr>
                            <tr style="background-color: silver">
                                <th class="col-sm-1 text-center">DP</th>
                                <th class="col-sm-1 text-center">Act</th>
                                <th class="col-sm-1 text-center">PB</th>
                                <th class="col-sm-1 text-center">GD</th>
                            </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                            <td><%# Eval("ID") %></td>
                             <td> <asp:Label ID="Qty" runat="server" ></asp:Label>  </td>
                            <td class="col-sm-1 text-center"><asp:Label ID="DP" runat="server" Text='<%# Eval("DP") %>'></asp:Label></td>
                            <td class="col-sm-1 text-center"><asp:Label ID="Act" runat="server" Text='<%# Eval("Act") %>'></asp:Label></td>
                            <td class="col-sm-1 text-center"><asp:Label ID="PB" runat="server" Text='<%# Eval("PB") %>'></asp:Label></td>
                            <td class="col-sm-1 text-center"><asp:Label ID="GD" runat="server" Text='<%# Eval("GD") %>'></asp:Label></td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                        </table>
                    </FooterTemplate>
                </asp:Repeater>
            </div>
        </form>


    In behind code

    Protected Sub LV_Report_ItemDataBound(sender As Object, e As RepeaterItemEventArgs)
            If (e.Item.ItemType = ListItemType.Item) Or
              (e.Item.ItemType = ListItemType.AlternatingItem) Then
                Dim DP = Convert.ToInt32(DirectCast(e.Item.FindControl("DP"), Label).Text)
                Dim Act = Convert.ToInt32(DirectCast(e.Item.FindControl("Act"), Label).Text)
                Dim PB = Convert.ToInt32(DirectCast(e.Item.FindControl("PB"), Label).Text)
                Dim GD = Convert.ToInt32(DirectCast(e.Item.FindControl("GD"), Label).Text)
                DirectCast(e.Item.FindControl("Qty"), Label).Text = DP + Act + PB + GD
    
            End If
        End Sub

    Best Regards

    Cathy

    Monday, January 16, 2017 9:45 AM