You must Sign In to post a response.
  • Category: ASP.NET

    2 level gridview grouping

    hello i have this data as below. how do i group those data by cd_dim_bhgn, followed by cd_dim_id.. help me please anyone. i really need help.. i don't know how to do nested or parent id or something related. TQ so much in advance.

    cd_id | cd_dim_id | cd_dim_bhgn | cd_que_bi | cd_que_bm
    1 | 1 | A | ABC | CDE
    2 | 1 | A | AAA | BBB
    3 | 1 | A | ccc | CCC
    4 | 2 | A | DDD | ddd
    5 | 2 | A | eee | EEE
    6 | 3 | A | FFF | fff
    7 | 3 | A | sss | SSS
    8 | 3 | A | qqq | QQQ
    9 | 4 | A | rrr | RSD
    10 | 4 | A | HHH | huh

    my expected result is like below:

    A
    1
    1
    1
    cd_que_bi | cd_que_bm
    A
    2
    2
    2
    cd_que_bi | cd_que_bm

    A
    3
    3
    3
    cd_que_bi | cd_que_bm
  • #768525
    Hi,

    as per my understanding the post if the same id contains no of child's then you want to show parent at once and for parent you want to show the child's right?

    If that is the case you have to customize your gridview templatefield like below.


    <asp:TemplateField HeaderText="Material" HeaderStyle-ForeColor="White">
    <ItemTemplate>
    <asp:Label ID="lblMaterial" runat="server" Text='<%# Bind_Material(Convert.ToString(Eval("Material_Name")))%>'/>
    </ItemTemplate>
    </asp:TemplateField>


    and in code behind you have to wrote code for Bind_Material


    protected string Bind_Material(string sMaterial)
    {
    if (Material == sMaterial)
    {
    sMaterial = "";
    }
    else
    {
    Material = sMaterial;
    }
    return sMaterial;
    }


    Try something like above to achieve your requirement, the output of the above is like below

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

    Delete Attachment

  • #768583
    i have solved the problem. tq for helping


  • Sign In to post your comments