Weird Character getting added to the column while selecting and saving dropdownlist option

I have a mvc application and have a dropdownlist but after selecting one of the options and saving it to sql database my column in the table shows a weird character like check this image with Approved there are weird characters and approved is one of the option in the dropdownlist (Untitled

are you using stored procedures to add the data or straight up insert into
is your drop down editable?

Hi @yosiasz,
No, iam not using any stored procedure.
My dropdown is getting value from the model class with a (IEnumerable function)
datatype for my column was nvarchar(50).

  1. Is the drop down read only as in users cannot mistakenly add characters to the drop down list?
  2. How are you inserting this data into the backend.
  3. Do you have a list of these statuses in a Status table you verify when inserting?


no it is just read only. One can only select cannot write anything.
2)through controller save .
3)no list of status in a table.
status is coming from the model class (and being called on controller than through viewbag to view)

We are using same function in another mvc application .It works perfectly fine.
I did a workaround changed my nvarchar(50) to varchar(8) just to take approved(as it has 8 char) but now it breaks my application ( that means the char is getting added again)

to the same server, same database??
WHat is the collation on these
sounds like an issue with your mvc not SQL. Post your .net or ?? code (that does the insert) here

Model class
public static IEnumerable getStatus()
IEnumerable status = new {"Approved", "Pending"};
return status;
private IEnumerable _stStatus = ProgramStatus.getStatus();

under edit
dayplan.Status2 = dayPlanViewModel.Status2;
ViewBag.Status2 = new SelectList(_stStatus, dayPlanViewModel.Status2);
db.Entry(dayplan).State = EntityState.Modified;

@Html.DropDownList("Status2", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Status2, "", new { @class = "text-danger" })

could it be a browser issue or encoding

code looks fine as far as I can tell.
have you tried different browsers? I doubt it is browser.
are you running this locally or is this mvc app already deployed to a web server?

also I would run SQL Profiler to see what is coming in the wire when the save is called.

I tried IE and chrome... for now error is seen on IE but not on chrome .

:grin::grin::grin::grin: IE :mask:

looks like you are not the first check this thread out

1 Like

Thanks a lot ! I hope this is the same problem like mine.