L
Lars
Hi
I have the following method. HOw do I performe the task to the table in the
database?
protected void FormView1_PageIndexChanging(object sender,
FormViewPageEventArgs e)
{
Button S = sender as Button;
if (S != null)
{
TextBox Name = (TextBox) S.Parent.FindControl("tbName");
TextBox Company = (TextBox) S.Parent.FindControl("tbCompany");
TextBox Email = (TextBox) S.Parent.FindControl("tbEmail");
TextBox Subject = (TextBox) S.Parent.FindControl("tbSubject");
TextBox Message = (TextBox) S.Parent.FindControl("tbMessage");
Label ID = (Label) S.Parent.FindControl("lblID");
SqlDataSource DS = (SqlDataSource)
S.Parent.FindControl("SqlDataSource1");
SqlDataSource1.InsertCommand = "insert into Emails (ID, Name,
Company, Subject, Message ) values ( @ID, @Name, @Company, @Subject,
@Message );";
if ((Name != null) && (Company != null) && (Email != null) &&
(Subject != null) && (Message != null) && (ID != null) &&
(DS != null) )
{
SqlDataSource1.InsertParameters["ID"].DefaultValue = ID.Text
+ 1;
SqlDataSource1.InsertParameters["Name"].DefaultValue =
Name.Text;
SqlDataSource1.InsertParameters["Company"].DefaultValue =
Company.Text;
SqlDataSource1.InsertParameters["Email"].DefaultValue =
Email.Text;
SqlDataSource1.InsertParameters["Subject"].DefaultValue =
Subject.Text;
SqlDataSource1.InsertParameters["Message"].DefaultValue =
Message.Text;
}
SqlDataSource1.
}
}
I have the following method. HOw do I performe the task to the table in the
database?
protected void FormView1_PageIndexChanging(object sender,
FormViewPageEventArgs e)
{
Button S = sender as Button;
if (S != null)
{
TextBox Name = (TextBox) S.Parent.FindControl("tbName");
TextBox Company = (TextBox) S.Parent.FindControl("tbCompany");
TextBox Email = (TextBox) S.Parent.FindControl("tbEmail");
TextBox Subject = (TextBox) S.Parent.FindControl("tbSubject");
TextBox Message = (TextBox) S.Parent.FindControl("tbMessage");
Label ID = (Label) S.Parent.FindControl("lblID");
SqlDataSource DS = (SqlDataSource)
S.Parent.FindControl("SqlDataSource1");
SqlDataSource1.InsertCommand = "insert into Emails (ID, Name,
Company, Subject, Message ) values ( @ID, @Name, @Company, @Subject,
@Message );";
if ((Name != null) && (Company != null) && (Email != null) &&
(Subject != null) && (Message != null) && (ID != null) &&
(DS != null) )
{
SqlDataSource1.InsertParameters["ID"].DefaultValue = ID.Text
+ 1;
SqlDataSource1.InsertParameters["Name"].DefaultValue =
Name.Text;
SqlDataSource1.InsertParameters["Company"].DefaultValue =
Company.Text;
SqlDataSource1.InsertParameters["Email"].DefaultValue =
Email.Text;
SqlDataSource1.InsertParameters["Subject"].DefaultValue =
Subject.Text;
SqlDataSource1.InsertParameters["Message"].DefaultValue =
Message.Text;
}
SqlDataSource1.
}
}