Monday, April 13, 2015

No mapping exists from object type System.Web.UI.WebControls.

I am getting the the message on the command:


Complete message is:

No mapping exists from object type System.Web.UI.WebControls.TextBox to
a known managed provider native type.

Solution: its actually a very silly mistake 

Seems as if  you set the DataBinding on the TextBox/Label itself instead of the Text property of the TextBox/Label?

for Example: 

cmdInsert.Parameters.Add(new SqlParameter("@LastName", txtLastName));

Instead of
cmdInsert.Parameters.Add(new SqlParameter("@LastName", txtLastName.Text));

No comments: