> public ContactEntity GetContactbyPk(Int32 con_pk) > { > this.GetDataSet("SELECT * FROM Contact WHERE con_pk = @conPk", > this.CreateParameter("@conPk", con_pk)); > return this.Entity; > } >>Now jumping to the form, the mmPicker's ItemSelected event is raised and the the above method called:
>private void pckStudent_ItemSelected(object sender, OakLeaf.MM.Main.Windows.Forms.mmPickerItemSelectedEventArgs e) > { > this.oContact.GetContactbyPk(this.pckStudent.Text); > } >In the pckStudent_ItemSelected() handler method you are pulling the value from the Text property of a text box. If you hover your mouse pointer over the Text property you will see it is a string. In order to pass the value stored in the Text property to the GetContactByPk() method, you must first convert it to an integer. To do this, you can use the int.Parse() method like this:
this.oContact.GetContactbyPk(int.Parse(this.pckStudent.Text));Now, all of that said, I'm thinking that the primary key of the item you select probably isn't being stored in the Text property of pckStudent...unless you have it set specifically to do this. The ItemSelected handler method is passed an <>mmPickerItemSelectedEventArgs <>object. You can examine the <>dsSelectedItems <>property of this event argument object to look at all columns of the item selected in the PickList control.
// Get the DataRow that contains the item selected in the PickList DataRow Row = e.dsSelectedItems.Tables[0].Rows[0]; // Specify the column name you want to retrieve a value from int SelectedItemPK = (int)Row["My_PK"];Best Regards,