By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,663 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,663 IT Pros & Developers. It's quick & easy.

creating drop down list at run time

P: n/a
hi

I have 2 drop down lists in my application.1st list ontains itmes like
java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the
items like 50,60,70,80,90,100.

i will select any skill in 1st drop down list then i'll select % of this
skill in the 2nd list box , based on the percentage i've selected in the 2nd
list box it has to display
2 sets of drop down list boxes at run time one for selecting skill and
another for selecting percentage of
skills it has to display these listboxes at run time upto total
percentage becomes 100.for e.g if i select java in 1st list
box and 60 in second list box then at run time below these 2 list boxes it
has to display another set of drop down lists. where i can select another
skill and for this skill i'll
select percentage.and i've to check the percentages
i've selected till now to know whether it has reached 100 %, if not i've to
disaply another set of drop down list boxes.

Hope you got what i said.

so for this wat i thought is to create dropdown list at run time.is it
possible to create drop down list at run time with the items.

can any one tell me how to add items to a drop down list which is created
at runtime.and how to get the value which i have selected in the drop down
list.am using html table on which am placing these controls.
each row in a table is having one control.

so if i want to create drop down list

control at run time i've to place it

for e.g. the 2 drop down list boxes are present at 3 row.and i've to
display newly created ones at 4rth row and so on.so i've to insert table row
at run time so that i can place newly created drop down list boxes on
this.can anybody tell me how to do this one.

Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Yoshitha,

You can put your First Dropdown list set in a Panel.
On SelectedIndexChange of the first drop down you can check the % value and
if <100 create a new <td> using LiteraControl, add it to the Panel and then
add your drop down list which is created dynamically.
For example:
DropDownList temp = new DropDownList();
temp.ID = "temp";

temp.Items.Add("10 % ");
temp.Items.Add("20 %");
temp.Items.Add("30 %");
temp.Items.Add("40 %");
temp.Items.Add("50 %");
temp.Items[0].Value = "10";
temp.Items[1].Value = "20";
temp.Items[2].Value = "30";
temp.Items[3].Value = "40";
temp.Items[4].Value = "50";

On checking the condition you can add the following code which will add <td>
and Drop down list to your panel.

Literal td_start = new Literal();
td_start.Text = "<td valign=top>";
panel1.Controls.Add(td_start);

panel1.Controls.Add(temp);

Literal td_end = new Literal();
td_end.Text = "</td>";
panel1.Controls.Add(td_end);

Hope this will help u.
Meena.

"Yoshitha" <gu**********@rediffmail.com> wrote in message
news:OC**************@TK2MSFTNGP15.phx.gbl...
hi

I have 2 drop down lists in my application.1st list ontains itmes like
java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100.

i will select any skill in 1st drop down list then i'll select % of this
skill in the 2nd list box , based on the percentage i've selected in the 2nd list box it has to display
2 sets of drop down list boxes at run time one for selecting skill and
another for selecting percentage of
skills it has to display these listboxes at run time upto total
percentage becomes 100.for e.g if i select java in 1st list
box and 60 in second list box then at run time below these 2 list boxes it
has to display another set of drop down lists. where i can select another
skill and for this skill i'll
select percentage.and i've to check the percentages
i've selected till now to know whether it has reached 100 %, if not i've to disaply another set of drop down list boxes.

Hope you got what i said.

so for this wat i thought is to create dropdown list at run time.is it
possible to create drop down list at run time with the items.

can any one tell me how to add items to a drop down list which is created
at runtime.and how to get the value which i have selected in the drop down list.am using html table on which am placing these controls.
each row in a table is having one control.

so if i want to create drop down list

control at run time i've to place it

for e.g. the 2 drop down list boxes are present at 3 row.and i've to
display newly created ones at 4rth row and so on.so i've to insert table row at run time so that i can place newly created drop down list boxes on
this.can anybody tell me how to do this one.

Nov 19 '05 #2

P: n/a
Hi Yoshitha,

You can put your First Dropdown list set in a Panel.
On SelectedIndexChange of the first drop down you can check the % value and
if <100 create a new <td> using LiteraControl, add it to the Panel and then
add your drop down list which is created dynamically.
For example:
DropDownList temp = new DropDownList();
temp.ID = "temp";

temp.Items.Add("10 % ");
temp.Items.Add("20 %");
temp.Items.Add("30 %");
temp.Items.Add("40 %");
temp.Items.Add("50 %");
temp.Items[0].Value = "10";
temp.Items[1].Value = "20";
temp.Items[2].Value = "30";
temp.Items[3].Value = "40";
temp.Items[4].Value = "50";

On checking the condition you can add the following code which will add <td>
and Drop down list to your panel.

Literal td_start = new Literal();
td_start.Text = "<td valign=top>";
panel1.Controls.Add(td_start);

panel1.Controls.Add(temp);

Literal td_end = new Literal();
td_end.Text = "</td>";
panel1.Controls.Add(td_end);

Hope this will help u.
Meena.

"Yoshitha" <gu**********@rediffmail.com> wrote in message
news:OC**************@TK2MSFTNGP15.phx.gbl...
hi

I have 2 drop down lists in my application.1st list ontains itmes like
java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100.

i will select any skill in 1st drop down list then i'll select % of this
skill in the 2nd list box , based on the percentage i've selected in the 2nd list box it has to display
2 sets of drop down list boxes at run time one for selecting skill and
another for selecting percentage of
skills it has to display these listboxes at run time upto total
percentage becomes 100.for e.g if i select java in 1st list
box and 60 in second list box then at run time below these 2 list boxes it
has to display another set of drop down lists. where i can select another
skill and for this skill i'll
select percentage.and i've to check the percentages
i've selected till now to know whether it has reached 100 %, if not i've to disaply another set of drop down list boxes.

Hope you got what i said.

so for this wat i thought is to create dropdown list at run time.is it
possible to create drop down list at run time with the items.

can any one tell me how to add items to a drop down list which is created
at runtime.and how to get the value which i have selected in the drop down list.am using html table on which am placing these controls.
each row in a table is having one control.

so if i want to create drop down list

control at run time i've to place it

for e.g. the 2 drop down list boxes are present at 3 row.and i've to
display newly created ones at 4rth row and so on.so i've to insert table row at run time so that i can place newly created drop down list boxes on
this.can anybody tell me how to do this one.

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.