Click here to Skip to main content
11,798,546 members (72,609 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Sorting combobox
I am trying to filter comboboxes populated with data from a local sqlserverce database. My task is to select one index in one combobox and have that result filter the next combobox. Would LINQ work for this or can I do it with just plain SQL? I am using Visual Studio 2010/2012 with SQL Server CE Edition. I would appreciate any help.
Posted 10-Sep-12 18:51pm
VijayChauhan123 at 11-Sep-12 1:06am
yes you can do it just by plain sql
VijayChauhan123 at 11-Sep-12 1:07am
Just write your code in the selectedIndex event of the first combobox.
ridoy at 11-Sep-12 1:19am
you can do it in both ways..only sql or only LINQ can do it.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


ofcourse you can use linq in this.

try this,

protected void combobox1_selectedIndexChanged(object sender, EventArgs e)
   //DataSet Objs holds data from sql server with two datatables one is source for combobox1 and other is source for combobox2
   DataTable dt = (from val in Objds.Tables[2].AsEnumerable() where val.Field<string>("Column1")== combobox1.SelectedValue select val).CopyToDataTable();
combobox2.DataSource = dt;

hope it helps.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 585
1 Maciej Los 395
2 OriginalGriff 348
3 Abhinav S 257
4 phil.o 254
0 OriginalGriff 2,150
1 Maciej Los 1,790
2 KrunalRohit 1,456
3 CPallini 1,415
4 Richard MacCutchan 1,016

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100