using DevExpress.Web.ASPxGridView;
string sqlquery = "INSERT INTO [Users] (FirstName,LastName)
VALUES (N@FirstName,N@LastName)";
SqlCommand command = new SqlCommand(sqlquery , connection);
string firstName = FirstNameTextBox.Text;
command.Parameters.AddWithValue("FirstName", firstName);
string lastName = LastNameTextBox.Text;
command.Parameters.AddWithValue("LastName", lastName);
public void getAllCtl(ControlCollection ctls)
{
foreach (Control c in ctls)
{
string testquery = "";
if (c is System.Web.UI.WebControls.TextBox)
{
TextBox tt = c as TextBox;
if (tt.Text != null)
{
testquery = "INSERT INTO [Table] (" + tt.ID + ") VALUES (N'" + tt.Text + "')";
}
connection.Open();
SqlCommand cmd = new SqlCommand(testquery, connection);
cmd.ExecuteNonQuery();
connection.Close();
}
if (c.HasControls())
{
getAllCtl(c.Controls);
}
}
}
public void getAllCtl(ControlCollection ctls)
{
foreach (Control c in ctls)
{
if (c is System.Web.UI.WebControls.TextBox)
{
TextBox tt = c as TextBox;
//to do something by using textBox tt.
}
if (c.HasControls())
{
getAllCtl(c.Controls);
}
}
}