이것은 간단 할 수 있지만 내 손가락에 넣을 수는 없습니다. 사용자가 만든 항목 목록이 들어있는 .aspx 페이지가 있습니다. 각 레코드와 연결된 링크가 있습니다. 해당 링크를 누르면 해당 레코드의 값이 사용자가 해당 레코드의 모든 필드를 편집 할 수있는 다른 페이지 (세부 정보 페이지)로로드됩니다. 모든 것이 잘 작동하고 간단합니다.업데이트 된 값이 전달되지 않음
그러나 세부 정보 제출 단추를 누르면 이전의 동일한 값이 다시 제출되고 현재 변경된 값은 다시 제출되지 않습니다. 그래서 나는 다른 [Id] 값을 가진 두 개의 동일한 레코드를 얻는다. 디버거에서 모든 것을 보았지만 새 값이 전달되지 않는 이유를 알 수 없습니다. 내가 C# 페이지에서 알고 있기 때문에 언제 내 저장 프로 시저를 실행하고 값을 수동으로 입력하면 모든 것이 올바르게 작동합니다.
무엇이 여기에 있습니까?
protected void SubmitDetails_Click(object sender, EventArgs e)
{
//Connection to the sql db and the stored procedure.
SqlConnection sqlConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand command = new SqlCommand("dbo.InsertDetailsRecords", sqlConn);
sqlConn.Open();
command.CommandType = CommandType.StoredProcedure;
//Parameters being passed to the stored procedure to go into the table.
command.Parameters.Add(new SqlParameter("@Date", (Datetxt.Text)));
command.Parameters.Add(new SqlParameter("@Title", (TitleBox.Text)));
command.Parameters.Add(new SqlParameter("@FirstName", (FirstNameBox.Text)));
command.Parameters.Add(new SqlParameter("@LastName", (LastNameBox.Text)));
command.Parameters.Add(new SqlParameter("@Comments", (CommentsBox.Text)));
command.Parameters.Add(new SqlParameter("@Categories", DropDownListCategory.SelectedValue));
command.Parameters.Add(new SqlParameter("@Centers", DropDownListCenters.SelectedValue));
command.Parameters.Add(new SqlParameter("@Status", DownListStatus.SelectedValue));
command.ExecuteNonQuery();
sqlConn.Close();
//Redirecting to the list page once the submit button is pressed.
Response.Redirect("List.aspx");
}
아마도 가장 일반적인 이유는'if (! Page.IsPostBack) DataBind();'입니다. –
제안 해 주셔서 감사합니다.하지만 여전히 중복 기록을 얻고 있습니다. :-) – Mracb