ASP.NET extensible grid view?

I found many different examples on the Internet, but nothing seems to do what I need.

I have a DB view that generates something like this:

-------------------------------------------------- -
Company | Code | Total | Available | Used | Needed
-------------------------------------------------- -
One | 1 | 10 | 8 | 2 | 3
One | 2 | 5 | 5 | 0 | 5
Two | 1 | 5 | 2 | 3 | 0
Two | 2 | 8 | 4 | 4 | nine
Two | 3 | 0 | 0 | 0 | 0
-------------------------------------------------- -

But I am really summarizing all the lines of the company for something and can expand to view the details as necessary.

Similarly:

-------------------------------------------------- ----
    Company | Total | Available | Used | Needed
-------------------------------------------------- ----
[+] One | 15 | 13 | 2 | 8
-------------------------------------------------- ----
[-] Two Code | 13 | 6 | 7 | nine
-------------------------------------------------- ----
            | 1 | 5 | 2 | 3 | 0
            | 2 | 8 | 4 | 4 | nine
            | 3 | 0 | 0 | 0 | 0
-------------------------------------------------- ----

I tried to build a gridview in a gridview for poor results.

I have a view that generates companies and consolidated information, if this cannot be done using JavaScript, which I assumed could be executed.

I'm just looking for free control or some bright idea on how I can do this. New to ASP.NET, so there may be something simple that I'm missing.

thanks

+3
2

, ListView.

Matt Berseth ListView .

+3

, - :

:

<ajax:Accordion ID="Accordion1" runat="Server" 
    SelectedIndex="0" 
    HeaderCssClass="accordionHeader"
    HeaderSelectedCssClass="accordionHeaderSelected" 
    ContentCssClass="accordionContent"
    AutoSize="None" FadeTransitions="true" 
    TransitionDuration="250" FramesPerSecond="40"
    RequireOpenedPane="false" SuppressHeaderPostbacks="true">
    <HeaderTemplate><%# Eval("Key")%></HeaderTemplate>
    <ContentTemplate>
    <asp:ListView runat="server" ID="MyListView" DataSource='<%# Eval("Values") %>'> 
        <LayoutTemplate> 
            <table style="width:75%"> 
                <tr> 
                    <th>Code</th> 
                    <th>Total</th>
                </tr> 
                <asp:PlaceHolder ID="itemPlaceholder" runat="server" /> 
            </table> 
        </LayoutTemplate> 
        <ItemTemplate>
            <tr> 
                <td><%# Eval("Code")%></td> 
                <td><%# Eval("Total")%></td>
            </tr> 
        </ItemTemplate> 
    </asp:ListView> 

    </ContentTemplate>
</ajax:Accordion>

Code-:

public class Company
{
    public string CompanyName;
    public int Code, Total;
    public Company(string company, int code, int total)
    {
        this.CompanyName = company; this.Code = code;
        this.Total = total;
    }
}

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        var Companies = new Company[] {
            new Company("One", 1, 10),
            new Company("Two", 1, 5),
            new Company("Two", 2, 8)
        };

        Accordion1.DataSource = Companies
            .GroupBy(c => c.CompanyName, c => new { Code = c.Code, Total = c.Total },
            (k, enumerable) => new { Key = k, Values = enumerable });
        Accordion1.DataBind();

    }
}
+2

Source: https://habr.com/ru/post/1715743/


All Articles