TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
daniel edun
NA
2
823
No mapping exists from object type System.Web.UI.WebControl
Nov 11 2015 6:47 AM
i dont know what i did wrong or didnt do but am confused as to how to solve this. please kindly help me out. when ever i run and try to enter data, its gives me error that "
No mapping exists from object type System.Web.UI.WebControl"
this is my code.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using System.Text;
using System.Windows;
namespace school_management_solution
{
public partial class WebForm3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ddlState.DataSource = GetData("spstate", null);
ddlState.DataBind();
ListItem listate = new ListItem("Select State", "-1");
ddlState.Items.Insert(0, listate);
ListItem lilocal = new ListItem("Select Local Gov", "-1");
ddlLocal.Items.Insert(0, lilocal);
ddlLocal.Enabled = false;
}
}
private DataSet GetData(string Spname, SqlParameter Spparameter)
{
string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
SqlConnection con = new SqlConnection(CS);
SqlDataAdapter da = new SqlDataAdapter(Spname, con);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
if (Spparameter != null)
{
da.SelectCommand.Parameters.Add(Spparameter);
}
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlState.SelectedIndex == 0)
{
ddlLocal.SelectedIndex = 0;
ddlLocal.Enabled = false;
}
else
{
ddlLocal.Enabled = true;
SqlParameter parameter = new SqlParameter("@ID", ddlState.SelectedValue);
DataSet ds = GetData("spgetlocalbystatid", parameter);
ddlLocal.DataSource = ds;
ddlLocal.DataBind();
}
}
protected void Button2_Click(object sender, EventArgs e)
{
string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
SqlConnection con = new SqlConnection(cs);
SqlCommand cmd = new SqlCommand("INS_Registration", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter Registration_ID = new SqlParameter("@Registration_ID", txtReg_ID);
SqlParameter Surname = new SqlParameter("@Surname", txtSurname.Text);
SqlParameter Last_name = new SqlParameter("@Last_Name", txtLast_name.Text);
SqlParameter Other_Name = new SqlParameter("@Other_Name", txtOther_Name.Text);
SqlParameter Date_Of_Birth = new SqlParameter("@Date_Of_Birth", txtDate_Birth.Text);
SqlParameter sex = new SqlParameter ("@Sex", rdbMale.);
SqlParameter Address = new SqlParameter ("@Address", txtAddress.Text);
SqlParameter Nationality = new SqlParameter("@Nationality", txtNationality.Text);
SqlParameter State_Origin = new SqlParameter("@State_Origin", ddlState.SelectedItem.ToString());
SqlParameter Local_govt = new SqlParameter("@Local_govt", ddlLocal.SelectedItem.ToString());
SqlParameter Phone_Number = new SqlParameter("@Phone_Number", txtPhone_Number.Text);
SqlParameter E_mail = new SqlParameter("@E_mail", txtE_mail.Text);
SqlParameter Picture = new SqlParameter("@Picture", PicturePre);
cmd.Parameters.Add(Registration_ID);
cmd.Parameters.Add(Surname);
cmd.Parameters.Add(Last_name);
cmd.Parameters.Add(Other_Name);
cmd.Parameters.Add(Date_Of_Birth);
cmd.Parameters.Add(sex);
cmd.Parameters.Add(Address);
cmd.Parameters.Add(Nationality);
cmd.Parameters.Add(State_Origin);
cmd.Parameters.Add(Local_govt);
cmd.Parameters.Add(Phone_Number);
cmd.Parameters.Add(E_mail);
cmd.Parameters.Add(Picture);
try
{
con.Open();
cmd.ExecuteNonQuery();
lblReport.Text = "Registration Inserted Complete";
}
catch(Exception ex)
{
lblReport.Text = ex.Message;
con.Close();
}
}
}
}
Reply
Answers (
2
)
ASP.NET MVC - How to show partial views with arraylist data
ASP.NET Radiobutton List Preserve Value