troubleshooting Question

textbox and dropdown is not  accepting the value in mvc

Avatar of sai krishnan
sai krishnanFlag for India asked on
.NET MVCMicrosoft SQL ServerC#
6 Comments2 Solutions153 ViewsLast Modified:
hi experts,
There is a text box for accepting phoneno and gender using dropdown. when i full the form with phone number and gender it is not accepting the entered value in textbox or dropdown for inserting.can anyone help me on this

in sql,it is inserting as 0 and dropdown as null

this is in cshtml
 <tr>
                <td>
                    @Html.LabelFor(a=>a.Phoneno)
                </td>
            </tr>

            <tr>
                <td>
                    @Html.TextBoxFor(a => a.Phoneno)
                    @Html.ValidationMessageFor(a => a.Phoneno)






                </td>

            </tr>
            <tr>
                <td>
                    @Html.Label("Gender")
                </td>
            </tr>

            <tr>
                <td>
                    @Html.DropDownListFor(a => a.gender, new List<SelectListItem>{

                    new SelectListItem {Text="Male",Value="0" },
                                        new SelectListItem {Text="Female",Value="1" }
              })
                    @Html.ValidationMessageFor(a => a.gender)


                </td>

in entity framework

 public int Phoneno { get; set; }
        public string gender { get; set; }


in controller
  mydbs itr = new mydbs();
            string result = itr.insertcmd(reg);
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros