I want to display the registration database in the same webpage where user registers. I can display by using the listview by configuring the database with it.
But i want to do that by using add item command in c#.
Another problem is even after i added the reference for the listview (system.web.ui.webcontrols) the Visualstudio says its ambiguous when i type listview.
my code is below
public void Insertfunc()//inserting into database
{
string database = @"Data Source=.;Initial Catalog=NewDB;Integrated Security=True";
SqlConnection myConn = new SqlConnection(database);
string queryStr = @"insert into Registration values (@fname,@lname,@dob,@emailid,@uname)";
SqlCommand myCommand = new SqlCommand(queryStr, myConn);
myCommand.Parameters.AddWithValue("@fname", FirstName);
myCommand.Parameters.AddWithValue("@lname", LastName);
myCommand.Parameters.AddWithValue("@dob", DateofBirth);
myCommand.Parameters.AddWithValue("@emailid", Mailid);
myCommand.Parameters.AddWithValue("@uname", UserName);
myConn.Open();
myCommand.ExecuteNonQuery();
myConn.Close();
string query = @"select * from Registration";
SqlCommand mycommand1 = new SqlCommand(query,myConn);
SqlDataReader tbl = mycommand1.ExecuteReader();
// i just want to add the listview coding here
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
public void Submit_Click(object sender, EventArgs e)
{
UserRegistration User1 = new UserRegistration();
int flag = 0;
User1.Mailid = mailid.Text;
User1.UserName = UN.Text;
User1.FirstName = FN.Text;
User1.LastName = LN.Text;
User1.DateofBirth = DOB.Text;
if (User1.Validatefunc(User1.Mailid, "[Email]") == true)
{
IDlbl.Text = "Provide Someother mailid";
}
else
{
IDlbl.Text = "Okay";
flag = 1;
}
if (User1.Validatefunc(User1.UserName, "[Username]") == true)
{
UNlbl.Text = "Username Not Available";
}
else
{
flag++;
UNlbl.Text = "Username Available";
}
if (flag == 2)
{
User1.Insertfunc();
}
}
}