Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1879
  • Last Modified:

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
0
kranthi4uonly
Asked:
kranthi4uonly
  • 3
  • 2
1 Solution
 
Bob LearnedCommented:
Are setting the DisplayMember and the ValueMember?

Bob
0
 
kosturdurCommented:
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).
HTH,
0
 
kranthi4uonlyAuthor Commented:
so can u pleasse help me how to d oia ma fresher so canu help me thanks
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
kosturdurCommented:
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.

0
 
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
0
 
kosturdurCommented:
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.
HTH,
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now