Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6781187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:35:41+00:00 2026-05-26T16:35:41+00:00

Ok I can’t seem to figure this one out..I have 1 table which has

  • 0

Ok I can’t seem to figure this one out..I have 1 table which has column id, parentid
this allows an option to have a sub-option. So it would be something like this:

id  |  parentid
1   |    null
2   |    null
3   |      1 

How I need it to show in my gridview is like this:

id  |  parentid
 1  |     null
 3  |      1
 2  |     null

any ideas I would be most greatful..and just in case I have searched and tried Sql COALESCE on the select but that didn’t work either..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:35:42+00:00Added an answer on May 26, 2026 at 4:35 pm

    I would use a ListView or DataList instead of a GridView. This should put you on the right path:

    <table width="595px">
        <asp:DataList BackColor="#ffffff" id="DataList1" DataKeyField="<ID>" OnItemDataBound="DataList1_ItemDataBound" runat="server" Width="100%">     
            <ItemTemplate>
               <tr>
                  <td>
                      <asp:LinkButton ID="LinkButton1" runat="server" Text="+" OnCommand="LinkButton1_Command" CommandArgument='<%#Container.ItemIndex%>'></asp:LinkButton>    
                  </td>
                  <td><%#Eval("<COLUMN NAME>")%></td>
                  <td><%#Eval("<COLUMN NAME>")%></td>
                  <td><%#Eval("<COLUMN NAME>")%></td>
               </tr>
               <asp:PlaceHolder ID="plcChildView" runat="server">
                   <asp:DataList ID="DataList2" runat="server" Width="100%">
                       <ItemTemplate>
                           <tr>
                              <td><%#Eval("<CHILD OLUMN NAME>")%></td>
                              <td><%#Eval("<CHILD COLUMN NAME>")%></</td>
                              <td><%#Eval("<CHILD COLUMN NAME>")%></</td>                           
                           </tr>
                       </ItemTemplate>
                   </asp:DataList>
               </asp:Panel>
            </ItemTemplate>
        </asp:DataList>
    </table>
    

    And when the user clicks the LinkButton/Button in DataList1, do something like this:

    protected void LinkButton1_Command(object sender, CommandEventArgs e)
    {
        //pass index of item in command argument
        int itemIndex = Convert.ToInt32(e.CommandArgument);      
    
        //find the pnlChildView control
        PlaceHolder childViewHolder = (PlaceHolder)DataList1.Items[itemIndex].FindControl("plcChildView");
        if (childViewHolder != null)
        {
            //toggle visibility of childViewPanel and bind child list if panel is visible
    
            if (childViewHolder.Visible)
            {
                DataList childList = childViewHolder.FindControl("DataList2");
                if (childList != null)
                {
                    int keyValue = (int)DataList1.DataKeys[itemIndex];
    
                    //bind the list using DataList1 data key value
                    childList.DataSource = <DATA SOURCE>; //get data using keyValue
                    childList.DataBind();
                }  
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can't figure out how to do this in a pretty way : I have
Can't seem to figure out what's wrong with the simple getJSON call below. It's
Can any one help me in sorting this out in sed/awk/perl Input file Start
Can someone help me with this scenario? *There is a button, which when tapped,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
Can anyone help me trying to find out why this doesn't work. The brushes
Can anyone direct me to a iOS6 tutorial on AVCam like this one: http://developer.apple.com/library/ios/#samplecode/AVCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010112
Can I order my users in the database, so I don't have to say
Can any one tell, how to get the result of LINQ query contains group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.