Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have a field with value "Additional Work" in sql database. But im not able to retrieve the value to dropdownlist. Without spaces it's accepting. how to accept the value with spaces.....
Posted
Comments
Greysontyrus 7-Feb-13 6:21am    
Please post the code showing how you are populating the dropdownlist.
Thanks
sukumari1 7-Feb-13 10:05am    
dropdownlist consists of
<asp:ListItem>Central Board Of Secondary Education
<asp:ListItem>TamilNadu Board Of Higher Secondary
<asp:ListItem>Matriculation Higher Secondary
<asp:ListItem>Anglo Indian

i already inserted the selected value (eg., Anglo Indian) in sql.
Another page has the selected values to be displayed in respective textboxes and dropdownlists.
Now i want Anglo Indian value from sql to be displayed first in the dropdown list
code : txtclass.SelectedValue = (objDataSet.Tables[0].Rows[0]["Class"]).ToString();
manognya kota 7-Feb-13 6:37am    
How are you populating your dropdown list ?

If you want to add elements by seprating with spaces then you can use String.split function and by seprating them by spaces you caan add them to dropdownlist
 
Share this answer
 
Comments
Greysontyrus 7-Feb-13 11:03am    
This answer does not relate to the question. That is exactly what sukumari1 doesn't want to do
There shouldn't be any issue with the
C#
txtclass.SelectedValue = (objDataSet.Tables[0].Rows[0]["Class"]).ToString();
, assuming that txtclass is actually a dropdownlist. Can you check that there are no rogue white spaces at the beginning or end of the list? The values should read <asp:ListItem>Anglo Indian</asp:ListItem>.
Any item you try to select with '.SelectedValue = ' must already be in the list and must be an exact match of the string between the tags
 
Share this answer
 
Comments
sukumari1 9-Feb-13 2:34am    
Correct. I deleted the space. It's working now.
Thanks.

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