EDN Admin
Well-known member
I have a simple project which is driving me crazy!!!
I have a .net asp page with a detailsView which is edit enabled.
One of the fields has been converted to a Template and in the EditItemTemplate I have placed a DropDownList with two values - No and Yes.
I created a SelectedIndexChanged event for this dropdown and placed the following code inside:
<pre class="prettyprint protected void DropDownList_DataIn_SelectedIndexChanged(object sender, EventArgs e)
{
using (SqlConnection sqlConn = new SqlConnection("Data Source=ukfil239win;Initial Catalog=FILPublishingSolutions;Integrated Security=True"))
{
string query = "UPDATE wf_main_v2 SET dataInDate = @dataInDate, Comments = @Comments WHERE id=103";
SqlCommand cmd = new SqlCommand(query, sqlConn);
cmd.Parameters.Add("@dataInDate", SqlDbType.DateTime).Value = DateTime.Now;
cmd.Parameters.Add("@Comments", SqlDbType.VarChar, 100).Value = "All Changed Now!";
cmd.Connection.Open();
try
{
cmd.ExecuteNonQuery();
}
catch (System.Exception ex)
{
}
finally
{
//Update the GridView with AJAX - code below refreshes the Gridview via a call from the trigger on the aspx page
//DetailsView1.DataBind();
LabelDataIn.Text = "Data In Changed";
}
}
}[/code]
All the code should do when the dropDownList item changes, is place a DateTime into the DataInDate row of the table and some comments into the comments box of the DV.
The change of No/Yes is reflected correctly in the table, but not the DateTime or Comments.
Any ideas why? <hr class="sig Lee Warren
View the full article
I have a .net asp page with a detailsView which is edit enabled.
One of the fields has been converted to a Template and in the EditItemTemplate I have placed a DropDownList with two values - No and Yes.
I created a SelectedIndexChanged event for this dropdown and placed the following code inside:
<pre class="prettyprint protected void DropDownList_DataIn_SelectedIndexChanged(object sender, EventArgs e)
{
using (SqlConnection sqlConn = new SqlConnection("Data Source=ukfil239win;Initial Catalog=FILPublishingSolutions;Integrated Security=True"))
{
string query = "UPDATE wf_main_v2 SET dataInDate = @dataInDate, Comments = @Comments WHERE id=103";
SqlCommand cmd = new SqlCommand(query, sqlConn);
cmd.Parameters.Add("@dataInDate", SqlDbType.DateTime).Value = DateTime.Now;
cmd.Parameters.Add("@Comments", SqlDbType.VarChar, 100).Value = "All Changed Now!";
cmd.Connection.Open();
try
{
cmd.ExecuteNonQuery();
}
catch (System.Exception ex)
{
}
finally
{
//Update the GridView with AJAX - code below refreshes the Gridview via a call from the trigger on the aspx page
//DetailsView1.DataBind();
LabelDataIn.Text = "Data In Changed";
}
}
}[/code]
All the code should do when the dropDownList item changes, is place a DateTime into the DataInDate row of the table and some comments into the comments box of the DV.
The change of No/Yes is reflected correctly in the table, but not the DateTime or Comments.
Any ideas why? <hr class="sig Lee Warren
View the full article