how to save ID of the record in the Database by taking the Name of the Record
MY application is in Silverlight(C#.Net) my requirement is i want to 开发者_C百科save the Id of the record. I have combo boxes(Eg:Country)in this combo the Name of the country is Displayed but while saving i want to save the ID of the Country.The Names of the Country are coming from Country Master.But there is another table which stores the ID's of country. How can i do this
The objects that are data bound to the combobox should have both attributes, ID and Name. The display ToString()
should be name. When a user picks a country from the combobox, save the corresponding ID back from the object they selected.
From the database side, a join or joiner table would be required to return the name and the ID if they are in separate tables.
Ideally, if this is a 1 to 1 relationship the name and the ID should be in the same table. If not, a database view could be used to join and query them.
Surely you have a table somewhere that associates a countryID with the countryName.
You then read this table to map the association.
If you do not have this table in any form, you have a significant design flaw.
精彩评论