TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nassira Elouali
NA
2
420
combobox depend another combobox problem
Feb 25 2018 10:54 AM
I wanna select from first combobox id of a train and in the second combobox give me the wagon that train has (number of a wagon ) I did a database: that first table stored the train id and the second table stored wagon id + id train foreign key i tried this code and its work but when i choose another id it doesn't change the wagon combobox result
What I have tried:
adapter =
new
SqlDataAdapter(
"select * from train"
, cn);
SqlCommand cmd =
new
SqlCommand(
"select * from train"
, cn);
cmd.Parameters.Clear();
adapter.Fill(ds,
"train"
);
comboBox1.DataSource = ds.Tables[
"train"
];
comboBox1.DisplayMember =
"id"
;
comboBox1.ValueMember =
"id"
;
adapter =
new
SqlDataAdapter(
"select id_w from wagon where id='"
+ comboBox1.SelectedValue +
"'"
, cn);
adapter.Fill(ds,
"wagon"
);
// adapter1.SelectCommand.Parameters.Clear();
comboBox2.DataSource = ds.Tables[
"wagon"
];
comboBox2.DisplayMember =
"id_w"
;
comboBox2.ValueMember =
"id_w"
;
Reply
Answers (
1
)
displaying google maps in MVC
Referencing a library