我想在用户注册的同一网页中显示注册数据库。我可以通过使用列表视图配置数据库来显示。
但我想通过在 c# 中使用 add item 命令来做到这一点。
另一个问题是即使在我添加了listview (system.web.ui.webcontrols)
Visualstudio 的引用后,当我键入 listview 时它仍然模棱两可。
我的代码在下面
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();
}
}
}