Dropdownlist set without SelecteIndex Property...
-
How i can set the dropdownlist without using Selectindex property. Because in my repeater control (where i am displaying dropdownlist data) , i don't have assoicated listindex values, i just have dropdown list text. I tried to use ((DropDownList)(FormView1.FindControl("CmbCountry"))).Text= "USA"; and i got erroe as below has a SelectedValue which is invalid because it does not exist in the list of items. Please help...
-
How i can set the dropdownlist without using Selectindex property. Because in my repeater control (where i am displaying dropdownlist data) , i don't have assoicated listindex values, i just have dropdown list text. I tried to use ((DropDownList)(FormView1.FindControl("CmbCountry"))).Text= "USA"; and i got erroe as below has a SelectedValue which is invalid because it does not exist in the list of items. Please help...
Amit Kumar G wrote:
has a SelectedValue which is invalid because it does not exist in the list of items.
OK, so you're on the right track, but the text you tried to set does not appear in the list. Therefore, if you use a string that does appear in the list, this is the right way to set the value by text instead of index. Isn't there also a findindex method ? Or you can iterate over the Items collection to find the one you want, to ensure it is there.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
How i can set the dropdownlist without using Selectindex property. Because in my repeater control (where i am displaying dropdownlist data) , i don't have assoicated listindex values, i just have dropdown list text. I tried to use ((DropDownList)(FormView1.FindControl("CmbCountry"))).Text= "USA"; and i got erroe as below has a SelectedValue which is invalid because it does not exist in the list of items. Please help...
oh dont worry... its easy just set dropdownlist_name.SelectedValue="USA" now test it and enjoy... msma www.toolsfa.com
-
oh dont worry... its easy just set dropdownlist_name.SelectedValue="USA" now test it and enjoy... msma www.toolsfa.com
Dear Mohsen, It is giving the same error CmbCountry' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value when i am doing ((DropDownList)(FormView1.FindControl("CmbCountry"))).SelectedValue = "USA";
-
Dear Mohsen, It is giving the same error CmbCountry' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value when i am doing ((DropDownList)(FormView1.FindControl("CmbCountry"))).SelectedValue = "USA";
test this code: for (int i = 0; i < [your repeater].Rows.Count; i++) { Control ctrl = gv_links_edit.Rows[i].Cells[0].FindControl("[your item name]"); DropDownList ddl= (DropDownList)ctrl; ddl.SelectedValue="USA"; } i use this code and i dont have any problem. good luck msma. www.toolsfa.com
-
Dear Mohsen, It is giving the same error CmbCountry' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value when i am doing ((DropDownList)(FormView1.FindControl("CmbCountry"))).SelectedValue = "USA";
Solved, In case some one is having similar probs. var lb = document.getElementById("FormView1_CmbCountry"); for(var i=0;i
-
Solved, In case some one is having similar probs. var lb = document.getElementById("FormView1_CmbCountry"); for(var i=0;i
This works ? It looks like javascript to me, and I thought the selected property could only be true or false ?
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )