My Code to be fired During Button
protected void Button2_Click(object sender, EventArgs e)
{
foreach (Control ctl in Dynamic.Controls)
{
if (ctl is TextBox)
{
TextBox tb = (TextBox)ctl;
using (SqlConnection con = new SqlConnection(_connStr))
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO DummyEntry(Sanskrit) VALUES(@S)"))
{
cmd.Connection = con;
cmd.Parameters.AddWithValue("@S", tb.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
}
}
PlaceHolder
<asp:PlaceHolder ID="Dynamic" runat="server">
</asp:PlaceHolder>
I am not able to find the TextBox inside Placeholder. The Ids are also randomly Generated .I debugged it but the code comes out of foreach loop .