المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Guid



C# Programming
09-18-2009, 02:41 PM
Hi,

How can I pass a Guid as a Parameter? I have the following method in my DAL but I cannot pass the value as Guid and I don't know how to do the conversion. I get this error "Specialized cast in not valid".

My method looks like this:

public dsWBGT GetPersonByUserId(Guid userId)
{
dsWBGT dsPerson = new dsWBGT();

WBGT.DAL.dsWBGTTableAdapters.PersonTableAdapter taPerson = new WBGT.DAL.dsWBGTTableAdapters.PersonTableAdapter();
taPerson.FillByUserId(dsPerson.Person, UserId);

return dsPerson;
}

Basically I am using ASPNET as the membership provider and I need to retrieve the user details based on the userID.

This is my method:

public void GetPersonByUserId()
{
frmUsers usersForm = frmUsers.GetChildInstance();

this.dsWBGT = personDataManager.GetPersonByUserId(UserId);
this.personBindingSource.DataSource = this.dsWBGT;
}

and finally my event looks like this:

private void dgvUsers_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 1)
{
Forms.Person.frmPerson personForm = new WBGT.Client.Forms.Person.frmPerson();

personForm.UserId = (Guid)dgvUsers.Rows[e.RowIndex].Cells[0].FormattedValue;
THIS IS WHERE IT FAILS :((
personForm.GetPersonByUserId();

personForm.MdiParent = frmMain.ActiveForm;
personForm.Show();
personForm.BringToFront();
}
}

Thank you!

Illegal Operation