If the SelectedValue = 3.5, 4.0 gets inserted?
My SqlDateType is Decimal(18,2)
Here is my DDL code:
<asp:RadioButtonList ID="skillLevelCmbo" runat="server" RepeatLayout="Table" RepeatDirection="Horizontal" CssClass="skillLevel" BackColor="#00f3ff">
<asp:ListItem Value="2.5">2.5</asp:ListItem>
<asp:ListItem Value="3.0">3.0</asp:ListItem>
<asp:ListItem Value="3.5">3.5</asp:ListItem>
<asp:ListItem Value="4.0">4.0</asp:ListItem>
<asp:ListItem Value="4.5">4.5</asp:ListItem>
<asp:ListItem Value="5.0">5.0</asp:ListItem>
<asp:ListItem Value="5.5">5.5</asp:ListItem>
<asp:ListItem Value="6.0">6.0</asp:ListItem>
</asp:RadioButtonList>
Here is my SP insert ADO.NET command:
protected void submitBtn_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["FMLConnection"].ToString());
SqlCommand cmd = new SqlCommand("dbo.spInsertUserProfileData", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@userName", HttpContext.Current.User.Identity.Name);
cmd.Parameters.AddWithValue("@firstName", fnameTB.Text);
cmd.Parameters.AddWithValue("@lastName", lnameTB.Text);
cmd.Parameters.AddWithValue("@userPhoneNumber", phnTB.Text);
cmd.Parameters.AddWithValue("@email", emailTB.Text);
cmd.Parameters.AddWithValue("@userStreetAddress", addressTB.Text);
cmd.Parameters.AddWithValue("@userCity", cityTB.Text);
cmd.Parameters.AddWithValue("@userState", Convert.ToString(DropDownListState.SelectedValue));
cmd.Parameters.AddWithValue("@userZipCode", zipCodeTB.Text);
cmd.Parameters.AddWithValue("@userBirthDate", DateTime.Parse(birthDate.Text));
cmd.Parameters.AddWithValue("@userYearsPlayed", Convert.ToInt32(noOfYearsTB.Text));
cmd.Parameters.AddWithValue("@userSkillLevel"(Convert.ToDecimal(skillLevelCmbo.SelectedValue)));
cn.Open();
IAsyncResult result = cmd.BeginExecuteNonQuery();
try
{
Session.Add("RegistrationComplete", result.IsCompleted);
cmd.EndExecuteNonQuery(result);
Response.Redirect("~/MyAccount");
}
catch (Exception ex)
{
errorsOccured.Text = "An error occurred: " + ex.Message;
}
finally
{
cn.Close();
}
}
Any suggestions would be greatly appreciated.