[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

data binding/navigation

Posted on 2006-06-07
4
Medium Priority
?
449 Views
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
ComboBox3--Description
ComboBox4--Location


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?

Thanks.

Yanci.
0
Comment
Question by:yanci1179
  • 2
4 Comments
 
LVL 2

Expert Comment

by:HeidarV
ID: 16858619

What are your tables and their columns?

heidar
0
 
LVL 12

Accepted Solution

by:
sumix earned 2000 total points
ID: 16859214

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) .
0
 

Author Comment

by:yanci1179
ID: 16860931


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!!

Yanci.







0
 

Author Comment

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

Heidi.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

830 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