data binding/navigation

Posted on 2006-06-07
Last Modified: 2008-03-06
I am using .net 2.0, have four comboboxes and 1 datagridview.

ComboBox1--hold values of a method
ComboBox2--holds values of a abbreviation it's the ID of the method

datagridview--phonenumbers email, basically contact info

All of the comboboxes are initially filled with values from look table.  What I would like to do is if the user where
to pick let's say location = '4521 never land' then combobox1,combobox2, and the datagrid would
show information that is relevant to that location.  Basically skip to that record.  Same for the other comboboxes, if combobox1 is changed that show relevant record,  

Currently, the form opens up is is binded with a datasource that has all to fields.  You can navigate on at a time.

Any suggestions of how I can go about this or where I can find a good example?


Question by:yanci1179
    LVL 2

    Expert Comment


    What are your tables and their columns?

    LVL 12

    Accepted Solution


    If you have set the DataSource property of the datagridview and of all the comboboxes to the same datasource (a bindingsource object for example) and you set the DisplayMember property for the comboboxes to 'Location', 'Description' etc., every time you select a record in one of the comboboxes or in the datagridview, that record will be current record for all the controls (the values of this row will appear in all comboboxes) .

    Author Comment


    the values of the comboboxes are coming from a look up table so don't they have to have a different datasource?

    here's what I'm doing:

    Ds = new DataSet()
    Cmd = new SqlCommand(SProc, CohortConn);
    Cmd.CommandType = CommandType.StoredProcedure;
    Da = new SqlDataAdapter(Cmd);
    Da.Fill(Ds, "tblMtdDesc");
    BindSrceMtd.DataSource = DsMtd;
    BindSrceMtd.DataMember = "tblMtdDesc";

    //Above, this datasource is the one that I'm using as the main source for all of my controls.  It contains all of the methods entered.

    //below: this is where I am getting the datasource from the look up tables for the comboboxes
    DsMtd = new DataSet()
    CmdMtd = new SqlCommand(SProcMtd, CohortConn);
    CmdMtd.CommandType = CommandType.StoredProcedure;
    DaMtd = new SqlDataAdapter(CmdMtd);
    DaMtd.Fill(DsMtd, "tblMtdAbb");

    DsDec = new DataSet()
    CmdDec = new SqlCommand(SProcDec, CohortConn);
    CmdDec.CommandType = CommandType.StoredProcedure;
    DaDec = new SqlDataAdapter(CmdDec);
    DaDec.Fill(DsMtd, "tblDec");

    BindSrceLkUp.DataSource = DsMtd;

    //below this is the the way that I'm binding the combobox that has the ID of every method used
      CbMtd.DataSource = BindSrceLkUp;
      CbMtd.DisplayMember = "tblMtd.Name_Lk",
      CbMtd.ValueMember = "tblMtd.ID_Lk";
      CbMtd.DataBindings.Add("SelectedValue", BindSrceMtd, "Mtd");

    //this is how I'm binding the combobox that has the description of each method (all should be unique)

      CbDec.DataSource = BindSrceLkUp;
      CbDec.DisplayMember = "tblDec.Name_Lk",
      CbDec.ValueMember = "tblDec.ID_Lk";
      CbDec.DataBindings.Add("SelectedValue", BindSrceMtd, "Dec");

    At this time, the controls are not synchronized.  When I change out combobox it does not change the other controls.  What am I doing wrong?

    Thanks for the help!!



    Author Comment

    okay, so I got it.  I joined the look up table within my stored procedure that way everything could be in one datasource.  Thanks!!


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    WiX Installer 2 38
    string format question 15 40
    Build VS2015 project in bat command 3 52
    send mail from 8 8
    Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    761 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

    10 Experts available now in Live!

    Get 1:1 Help Now