I have one datalist which retrives record from database based of Customer_ID

<asp:DataList ID="DataList1" runat="server" DataKeyField="Customer_ID" 
            DataSourceID="SqlDataSource1" onupdatecommand="DataList1_UpdateCommand" 
            oneditcommand="DataList1_EditCommand1" 
            ondeletecommand="DataList1_DeleteCommand" 
                    oncancelcommand="DataList1_CancelCommand1">
            <HeaderTemplate>  
        <table>  
            <tr>  
                <th style="width: 250px">  

                </th>  
                <th style="width: 400px">  
                    Item Description  
                </th> 
                <th style="width: 100px">  
                    Price
                </th> 
                <th style="width: 100px">  
                    Qty
                </th>  
            </tr>  
    </HeaderTemplate> 
            <ItemTemplate>
             <tr>  
            <td> 
                <asp:Image ID="Image1" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Product_Image") %>' Width="100px" Height="150px" />  
            </td>  
            <td>  
                <%# DataBinder.Eval(Container.DataItem, "Item_Description") %>  
            </td>  
            <td>  
                <%# DataBinder.Eval(Container.DataItem, "Price") %>  
            </td>  
            <td>  
                <%# DataBinder.Eval(Container.DataItem, "Qty") %>  
            </td>  
            <td>  
                <asp:LinkButton ID="lnkEdit"   
                    runat="server"   
                    CommandName="edit">  
                    Change  
                </asp:LinkButton>  
            </td>  
            <td>  
                <asp:LinkButton ID="LinkButton1"   
                    runat="server"   
                    CommandName="delete">  
                    Delete
                </asp:LinkButton>  
            </td>  
        </tr>  
            </ItemTemplate>
            <EditItemTemplate>  
        <tr>  
            <td>  
                <asp:Image ID="Image2" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Product_Image") %>' Width="100px" Height="150px" />  
            </td>
            <td>  
                 <%# DataBinder.Eval(Container.DataItem, "Item_Description") %>  
            </td>
            <td>  
                 <%# DataBinder.Eval(Container.DataItem, "Price") %>  
            </td>  
            <td>  
               <asp:TextBox ID="TextBox1"   
                    runat="server"   
                    Text='<%# DataBinder.Eval(Container.DataItem, "Qty") %>'>
                </asp:TextBox>  
            </td>  
            <td>  
                <asp:LinkButton ID="lnkUpdate"   
                    runat="server"   
                    CommandName="update">  
                    Update  
                </asp:LinkButton>  
                <asp:LinkButton ID="lnkCancel"   
                    runat="server"   
                    CommandName="cancel">  
                    Cancel  
                </asp:LinkButton>  
            </td>  
        </tr>  
    </EditItemTemplate>  
    <FooterTemplate>  
    <td>
        </table>  
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </FooterTemplate> 
        </asp:DataList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
             ConnectionString="<%$ ConnectionStrings:OnlineShopConnectionString2 %>" 
                SelectCommand="SELECT [Customer_ID] ,[Product_Image], [Item_Description], [Price], [Qty] FROM [Cart]"
             UpdateCommand="UPDATE [Cart] SET [Qty] = @Qty WHERE [Customer_ID] = @original_CustomerID"
             DeleteCommand="delete from [Cart] WHERE [Customer_ID] = @original_CustomerID and [Product_Image]=@Product_Image" >
             <DeleteParameters>
             <asp:Parameter Name="Qty" Type="String" />
             <asp:Parameter Name="Product_Image" Type="String" />

              <asp:Parameter Name="original_CustomerID" Type="Int32" />
             </DeleteParameters>
            <UpdateParameters>
               <asp:Parameter Name="Qty" Type="String" />

              <asp:Parameter Name="original_CustomerID" Type="Int32" />
            </UpdateParameters></asp:SqlDataSource>

Suppose for example the user has buyed 6 products .......
prices such as 100,200,340,768,977,876
I want to get total of all this in a label which is in footer
How can i do that the number of products buyed by user may vary from person to person

Need Help An Idea Could Help.....................

I think the easiest way to do this is to place a label in the footer, and in your code behind, create another SQL query that simply returns the sum. Then assign that data to the text property of your label.

So your SQL query would be (based on the query above):
SELECT sum([Price]) FROM [Cart] WHERE Customer_ID = ?

Its so simple why didnt it clicked me.....
looks like i was making it look difficult by myself....thanks JorgeM

Not a problem. come back with an update if needed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.