Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am using 3 combo boxes.
1.fist box select in table names.
2.display column names in which select table name.
3.select column name then display the all data.
i am write code for first 2 combo boxes using while loop. so old data also repeated. then please give any idea to solve this problem.
Posted

1 solution

C#

Do like this

for binding first combo say --dropdownlist1
make sure
C#
autopostback=true 
property will be true
C#

dropdownlist1.items.clear();

C#
sql="your sql query for filling table names";
//fill data into a data set say ds
<pre>dropdownlist1.datasource=ds;
dropdownlist1.datatextfield= "textfield name";
dropdownlist1.datavaluefield="value field name";
dropdownlist1.databind()

ds.clear();

for binding first combo say --dropdownlist2
make sure
C#
sql2="your sql query for filling table columname where tablename=" + dropdownlist1.selectedvalue;
<pre lang="cs">//fill data into a data set say ds1

<pre>autopostback=true 
property will be true

C#
dropdownlist2.items.clear();

dropdownlist2.datasource=ds1;
dropdownlist2.datatextfield= "textfield name";
dropdownlist2.datavaluefield="value field name";
dropdownlist2.databind()

ds1.clear();
XML
for binding first combo say --dropdownlist2
make sure <pre lang="c#"><pre>autopostback=true </pre></pre>property will be true

sql3="your sql query for filling data of your column where columnname=" + dropdownlist2.selectedvalue;
<pre lang="cs">//fill data into a data set say ds2

dropdownlist3.items.clear();

dropdownlist3.datasource=ds3;
dropdownlist3.datatextfield= &quot;textfield name&quot;;
dropdownlist3.datavaluefield=&quot;value field name&quot;;
dropdownlist3.databind()</pre>

ds3.clear();


may it will help you...
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900