Gridview to select from "Parent" into "Child" elements

Posted on 2011-10-23
Last Modified: 2012-05-12
Hi all,

Answered my fair share of questions in my time mostly in the PowerShell zone, but I am in need of help on something I am not so familiar with! :)

Basically I have some tables in a SQL 2008 Database that are interlinked, consider the attached image which shows how my tables link together.

In the long run though I consider the subscriptions table the parent table. The exch_mailboxes table is the child table and they link together via the exch_domain_services table.

The accounts table has a one to many relationship to the subscriptions table and I included it just so for searching purposes we may be able to search by name instead of subscription ID. The exch_mailboxes_addresses table just lets us pull back email addresses for users.

What I would like to do is have users search for a subscription (accounts may have multiple subscriptions) using the accounts/subscription tables, and then select a subscription, and then be taken into the child elements which will contain the exchange users that belong to that subscription.

I will then worry about letting people make adjustments from that point, but first things first I need to get this working.

I am using ASP.NET C# as my coding language, and I have Visual Studio 2010 which I am somewhat familiar with.

My experience so far has been using Datasets with TableAdapters, SQL stored procs and the GridView controls so those I am familiar with, if it's possible to carry on using those for this it would probably make things easier for me.

I am not afraid to use the codebehind pages for things but less familiar with that than using the GUI for the controls like I have been using.

Any help appreciated!

Chris nBUNs.png
Question by:chrismerritt
    LVL 96

    Expert Comment

    by:Bob Learned
    I don't quite see a question.  What would you like to do with the GridView?
    LVL 9

    Author Comment

    To cut a long story short, I would like a gridview that is populated with subscription data (from the subscriptions table in my screenshot) to be selectable.

    When a subscription is selected another gridview becomes populated with the child elements of that subscription (these are the values form the exch_mailboxes table).

    These child elements ideally would be editable en masse via checkboxes or similar.

    Does this make more sense?
    LVL 10

    Expert Comment

    Hi Chris...

    Basically there are two ways to use a gridview: wizard or manual.  The wizard is a fast way from the design screen in VS to create a gridview real fast without using code...
    In Visual Studio after you create or after you create a web site or open a web site...drag a gridview from the toolbox onto the
     web form and use the smart tag to reference whatver you datasource you want, you can custom your query..

    See this link for more details...FYI, the manual way is so you can use a pure code solution fro absolute control.

    this specifically in the link:
    To add any of the data source controls to an ASP.NET page, simply drag them from the Visual Studio 2005 Toolbox onto the appropriate ASP.NET Web page's Design view. Once you do this, the control's Smart Tag will appear with an option titled "Configure Data Source." Choosing this option will launch a wizard that prompts for the requisite information.
    LVL 9

    Author Comment

    Sorry GlobalLevel I don't think you understood my question totally, I am fine with adding data sources to gridviews via the table adapters, what I am not sure about is how I can go about selecting data from one gridview and then utilising this to fill another gridview or similar.

    Think of it like this, you have a ticketing system for a support desk, and you want to be able to browse from a particular company into all tickets belonging to that company.

    What I would like to be able to do is select the company in the first grid view, then when selected a second gridview/detailsview gets populated with all the tickets belonging to the company I selected just now.

    Does this make sense?
    LVL 96

    Expert Comment

    by:Bob Learned
    That sounds like you want to use a control parameter for a second data source that is bound to a child GridView/DetailsView.
    LVL 9

    Author Comment

    Hi LearnedOne,

    Sorry for delay in getting back to you, i've been pretty busy.

    That does sound right, but unfortunately for me I have no idea how to begin with this to be perfectly honest, any chance you could post me a simple example or some sample code or something to get me started?
    LVL 96

    Accepted Solution


    ControlParameter Class

              connectionstring="<%$ ConnectionStrings:MyNorthwind%>"
              selectcommand="SELECT LastName FROM Employees WHERE Title = @Title">
                  <asp:controlparameter name="Title" controlid="DropDownList1" propertyname="SelectedValue"/>

    Open in new window

    LVL 9

    Author Comment

    I'm not totally convinced this question ever got answered to my satisfaction. But I can't open a new question until this one is marked as answered, and despite EE emailing me telling me my question was going to be automatically closed it never actually did get closed. So I am going to mark it as answered anyway.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
    This video discusses moving either the default database or any database to a new volume.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now