Info GridView RRS feed

  • Question

  • User-12314477 posted

    Hi guys,

    It's my first post.

    I'm writting to ask help about a new project. I've to undestand the better model to use for the core page of this new project.

    I need to build a particular grid with dinamically columns, cliccking on a cell it will open a new form with all the detail


                     | Company, investors | Company, investors | .... |

    range time | Company, investors | Company, investors | .... |

    range time | Company, investors | Company, investors | .... |

    ...              | ...                            | ...                           | .... |

    Is it possibile used gridview nested or list view + gridview?

    many thanks,


    Tuesday, December 18, 2018 11:30 AM

All replies

  • User753101303 posted


    On my side I still don't fully get the kind of UI you want. This is a single company name and list of investors maybe grouped on some time information ? You'll have the same company name in each column or it could vary from one line to the next ?

    I'm not sure yet a grid view is your best option. I wonder if it couldn't be shown as series of "tiles".

    Tuesday, December 18, 2018 2:56 PM
  • User-893317190 posted

    Hi Ste81,

    You could use  a link in your main page and set its target to _blank to open a new form of all the detailed information.

    Below is my code.

     <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID" DataSourceID="SqlDataSource1">
                    <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" />
                    <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                            <a href='<%# "/gridview3/oneToManyExe/showDetail.aspx?id="+Eval("CategoryID") %>' target="_blank">go to detail</a>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:WingtipToysConnectionString2 %>" SelectCommand="SELECT * FROM [Categories]"></asp:SqlDataSource>

    Page of child form.

       <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID" >
                    <asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False" ReadOnly="True" SortExpression="ProductID" />
                    <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
                    <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                            <asp:Image ID="Image1" runat="server" ImageUrl='<%# "/images/WingtipToys/"+Eval("ImagePath") %>' />
                    <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />

    Code behind of child page.

     protected void Page_Load(object sender, EventArgs e)
                if (!IsPostBack)
                  int id =  Request["id"] == null ? 1 : int.Parse(Request["id"]);
                    using (SqlDataAdapter adapter = new SqlDataAdapter("select * from Products where categoryId =@id", constr))
                        adapter.SelectCommand.Parameters.AddWithValue("id", id);
                        DataTable table = new DataTable();
                        GridView1.DataSource = table;

    The result.

    If you want to use nested gridview, you could refer to the code below.


    Best regards,

    Ackerly Xu

    Wednesday, December 19, 2018 4:09 AM