Sunday, December 8, 2024

Grid view or Dropdown with SQL datasource

 <asp:GridView runat="server" ID="grdSalesReportCustomer" AutoGenerateColumns="False" DataSourceID="SalesReportCustomer">

                        <Columns>

                            <asp:BoundField DataField="Name" HeaderText=" Customer Name" SortExpression="Name"></asp:BoundField>

                            <asp:BoundField DataField="TotalAmountSpent" HeaderText="Total Amount Spent" ReadOnly="True" SortExpression="TotalAmountSpent"></asp:BoundField>

                        </Columns>

                    </asp:GridView>




                    <asp:SqlDataSource runat="server" ID="SalesReportCustomer" ConnectionString='<%$ ConnectionStrings:ConStringTrainee %>' SelectCommand="select  cm.Name, sum(pd.Total_Price) as TotalAmountSpent from Purchase_Details pd inner join Customer_Master cm on cm.Customer_ID= pd.Customer_ID group by pd.Customer_ID, cm.Name"></asp:SqlDataSource>


in c# code

on save click

 grdSalesReport.DataSourceID = "BookSalesReport";

            grdSalesReport.DataBind();

No comments:

Post a Comment