Drop Down Lists on web pages problem
-
Hi all, i have an intermediate knowledge on asp.net and am using Vs2005 to write the programme. i have two drop down lists on my web page and whenever i try to set the selected text, it always changes to the second one. here is a short code snippet. ************************************************************************ dim dt as new datatable dt = GetData() me.dropdownlist1.Text = CTYPE(dt.rows(0).item("Consultant1"),string).trim me.dropdownlist1.Text --> "Harry" me.dropdownlist2.Text = CTYPE(dt.rows(0).item("Consultant2"),string).trim me.dropdownlist1.Text --> "George" me.dropdownlist2.Text --> "George" ************************************************************************* when stepping through the code above the first drop down is initially correct but changes after the code passes over drop down 2.What am i doing wrong? Could you help with this, please! :sigh: Anoop Brijmohun
-
Hi all, i have an intermediate knowledge on asp.net and am using Vs2005 to write the programme. i have two drop down lists on my web page and whenever i try to set the selected text, it always changes to the second one. here is a short code snippet. ************************************************************************ dim dt as new datatable dt = GetData() me.dropdownlist1.Text = CTYPE(dt.rows(0).item("Consultant1"),string).trim me.dropdownlist1.Text --> "Harry" me.dropdownlist2.Text = CTYPE(dt.rows(0).item("Consultant2"),string).trim me.dropdownlist1.Text --> "George" me.dropdownlist2.Text --> "George" ************************************************************************* when stepping through the code above the first drop down is initially correct but changes after the code passes over drop down 2.What am i doing wrong? Could you help with this, please! :sigh: Anoop Brijmohun
i'm not fully understand what your problem is. do you want to assign your each ddl's text or item? if item, you have to bind your ddl first with data, set selectedvalue and selectedtext then bind it. ddl.datasource = bla2 ddl.selectedvalue = bla2 ddl.selectedtext = bla2 ddl.databind() then select ddl.selectedvalue with your specific item. be careful if you want to assign with something that "by reference". sometimes if you don't assign it correctly, the result will goes like your problem like now. hope it helps
-
i'm not fully understand what your problem is. do you want to assign your each ddl's text or item? if item, you have to bind your ddl first with data, set selectedvalue and selectedtext then bind it. ddl.datasource = bla2 ddl.selectedvalue = bla2 ddl.selectedtext = bla2 ddl.databind() then select ddl.selectedvalue with your specific item. be careful if you want to assign with something that "by reference". sometimes if you don't assign it correctly, the result will goes like your problem like now. hope it helps
Hi thanks for you help, Sorry should have mentioned this initially. My ddl's has items already in its collection, namely Harry, George. which are static i am reading and storing data into the datatable dt, which has 2 columns - Consultant1 and Consultant2. the problem i am experiencing is that when i assign ddl1 its value(Consultant1) and go to ddl2 and assign its value(Consultant2), ddl1 some how also gets assigned ddl2 value. ddl1 loses it value of harry and picks up George....... i have noe clue why... hope this helps....
-
Hi thanks for you help, Sorry should have mentioned this initially. My ddl's has items already in its collection, namely Harry, George. which are static i am reading and storing data into the datatable dt, which has 2 columns - Consultant1 and Consultant2. the problem i am experiencing is that when i assign ddl1 its value(Consultant1) and go to ddl2 and assign its value(Consultant2), ddl1 some how also gets assigned ddl2 value. ddl1 loses it value of harry and picks up George....... i have noe clue why... hope this helps....
hello anoop, i'm sorry due to late to reply, because yesterday was chineses new year holiday. with how you assign the value of ddl? is it with ddl.selectedvalue ? if it doesnt work until you want to punch your monitor, why dont you fill you ddl's item dynamiclly? ddl.item.clear() ddl.item.add(new listitem("text","value")); hope it helps.. im sorry if im too late