combo box dispaly memeber ,value in c# windows form

i had a combo box  the field length of it is 1 char in database but the user should be able to see "default " and "override" text in combobox . how to store it in the collection so that it should be 1 char in storage but the displaymember should be "overide" or "default" this is "windowsform" app
plse help me
Who is Participating?
hi kranthi4uonly,
In Solution Explorer right-click to your project and select "add" then select "new item" then choose a dataset. From Menu-->View-->Server Explorer get connected to your database, find your table then drag&drop your table into the dataset. Then right click to the table on the dataset and choose configure. While configuring your sql string instead of default sql write;
 SELECT    A, B, MyField, (CASE WHEN MyField = 'd' THEN 'default' ELSE 'override' END) AS MyFieldExplanation
FROM         MyTable
then menu -->data--->datasources-->show datasources before dropping your fields change the MyFieldExplanation to combobox by selecting from the dropdown near the field. Now you can see the 'default' and 'override' but I don't know how you manage the update, insert, delete events. You could do this by code from another dataset and then refresh this one. You could open another topic for that.
Bob LearnedCommented:
Are setting the DisplayMember and the ValueMember?

I think your problem is starts with your database design. Changing your database field to bit(bool) and use radio button or changing your database field to varchar(x)  and use combobox could solve your problem. Or you could use a view dataset (select ...CASE myfield=d then "default" else "override") get(show) your data with combobox and table dataset to update your data(you should collect the data by yourself from your form's controls).
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

kranthi4uonlyAuthor Commented:
so can u pleasse help me how to d oia ma fresher so canu help me thanks
Sure kranthi4uonly,
If I were you I would change the database strucure because there is no meaning to use char(1) in your database.
If you use this field many times in your applications and database structure and want your database size smaller and your database faster(if you have a large database) you can change it to bit(1 or 0) could be solution.
Or if your database is not large and there is no need to performance and you need this field as string in your code, change it to varchar(8) and it will became more easy to manage this field.

You must decide which one do you prefer?

Then if your database have data, I will help you change the database's meta data.
if not it is a piece of cake :)
I'm waiting for your decision.

kranthi4uonlyAuthor Commented:
hi kosturdur
i cant change database it is not in my hands and hte databse holds some thousand s at tiems milions of records so it is not posible ot do change it

and one more thing is iam using  menu -->data--->datasources and if u do show datasources u wil get all the colum names of the datatable on left side  so i selected combobox for that colum and draged it on form so automaticaly it will bind to the colum and the xml fiel will be created so before binding itself i have to do some thing so how to do it frm here please help me
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.