I am generating dynamic textbox for that I have 2 tables:
- dynamic
- empdetail
Here empdetail is a master table and dynamically generated column is inserted in that table and after that I also want to store data in database. But the problem is when i save the dynamic textbox value in database, the value will be insert null in database i cant see the dynamic textbox value...
Pls help me to solve my problem. My code is below...... My Dynamic TextBox id is="TxtDynamic"
protected void Button3_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=vaio\\sqlexpress;Initial Catalog=emp;User ID=sa;Password=administrator";
con.Open();
//TextBox tb = (TextBox)Panel1.FindControl("TxtDynamic" + i.ToString());
string query = "update empdetail set " + TextBox1.Text + " = '"+ Panel1.FindControl("TxtDynamic1" + i.ToString()) + "' where id=(select Max(id) from empdetail )";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();
}