Rick,
>It's a compile time error. Here is the actual error:
>
>Error 4 Cannot convert type 'string' to 'int' H:\MM\Voting System\Voting System\ElectionMaintenanceForm.cs 39 64 Voting System
>
>
>Here is the code:
>
> private void pckElection_ItemSelected(object sender, mmPickerItemSelectedEventArgs e)
> {
> this.dsBallot = this.oBallot.GetBallotByElectionPK((int)this.pckElection.Text);
> this.btnNew.Enabled = true;
> }
There are a few issues here
- 1. In C#, if you want to convert a string to an integer, you must use the Parse command. For example:
int.Parse(this.pckElection.Text);
- You mentioned there are two columns in the table, OfficePK and Title. Typically, you want to display the description in the picker text box and NOT display the OfficePK (it's usually a system-generated key).
If this is the case, you don't want to grab the OfficePK value from the textbox, but rather derive it from the event arguments in the PickList's ItemSelected() event handler. All items selected in a picklist are stored in the event arguments's dsSelectedItems property. For example (using an untyped data approach):int OfficePK = (int)e.dsSelectedItems.Tables[0].Rows[0]["OfficePK"];
this.dsOffice = this.oOffice.GetOfficeByOfficePK(OfficePK);
Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com