在我的代码中插入了非常必要的行之后-
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
try {
GridViewRow row = GridView1.SelectedRow;
AccountNumber.Text = (string)row.Cells[0].Text;
.....
if (DropDownListCurrency.Items.FindByValue(row.Cells[7].Text.ToString().Trim()) != null)
{
DropDownListCurrency.SelectedValue = row.Cells[7].Text.ToString().Trim();
}
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);
}
}
没有抛出任何错误,并且所有字段都按照它们应该在相应的下拉框和文本框中进行填充。但是我的保存和插入语句不再起作用。帮助!
protected void AgentSave_Click(object sender, EventArgs e)
{
try
{
SqlConnection con = new SqlConnection("XX");
SqlCommand command = con.CreateCommand();
command.CommandText =
"Insert into ABC values('" + AccountNumber.Text + "','" + Name.Text + "','" + Address1.Text + "','" + Address2.Text + "', '" + Address3.Text + "','" + PhoneNumber.Text + "','" + FaxNumber.Text + "','" + DropDownListCurrency.Text + "')";
con.Open();
command.ExecuteNonQuery();
con.Close();
Response.Redirect("main.aspx");
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);
}
}