user2167089
user2167089

Reputation: 151

Cannot convert string to Guid

I want to get selection made in a dropdown and store it.

How can I fix this error for when setting value from dropdown dropmarket?

Cannot implicitly convert type 'string' to 'System.Guid'

cellsite.Market.MarketID = dropmarket.SelectedValue;

Upvotes: 0

Views: 4216

Answers (1)

Albin Sunnanbo
Albin Sunnanbo

Reputation: 47038

Change to

cellsite.Market.MarketID = Guid.Parse(dropmarket.SelectedValue);

A string is not implicitly convertible to a Guid. You use the Guid.Parse method to convert a string to a Guid.

Upvotes: 1

Related Questions