Click here to Skip to main content
13,150,385 members (29,279 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 11-Sep-12 1:06am
yes you can do it just by plain sql
VijayChauhan123 11-Sep-12 1:07am
Just write your code in the selectedIndex event of the first combobox.
ridoy 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170924.2 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2017
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