我需要有关此Gridview问题的帮助。我在Gridview基础上根据ID构建下拉列表搜索,如下图所示
我遇到的问题是,当我单击“编辑”按钮更新Gridview时,Gridview的值会更改并返回到表格中的第一个值,如下图所示
C#代码GridViewMYD88_RowUpdating
protected void GridViewMYD88_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = GridViewMYD88.Rows[e.RowIndex];
Label TestID = (Label)GridViewMYD88.Rows[e.RowIndex].FindControl("lblId");
Label SampleBranchID = (Label)GridViewMYD88.Rows[e.RowIndex].FindControl("lblSampleBranchID");
string TechniqueforMYD88 = (row.FindControl("txtTechniqueforMYD88") as TextBox).Text;
string MYD88ExonsAnalyzed = (row.FindControl("txtMYD88ExonsAnalyzed") as TextBox).Text;
string SequenceofEntireMYD88 = (row.FindControl("txtSequenceofEntireMYD88") as TextBox).Text;
string MYD88MutationStatus = (row.FindControl("txtMYD88MutationStatus") as TextBox).Text;
string NumberofMYD88Mutations = (row.FindControl("txtNumberofMYD88Mutations") as TextBox).Text;
string MYD88pL265PMutation = (row.FindControl("txtMYD88pL265PMutation") as TextBox).Text;
string OtherMYD88MutationDescription = (row.FindControl("txtOtherMYD88MutationDescription") as TextBox).Text;
string MYD88VAFPercentage = (row.FindControl("txtMYD88VAFPercentage") as TextBox).Text;
string MYD88RefAllelesReads = (row.FindControl("txtMYD88RefAllelesReads") as TextBox).Text;
string MYD88VariantAllelesReads = (row.FindControl("txtMYD88VariantAllelesReads") as TextBox).Text;
string MYD88OverallReadDepth = (row.FindControl("txtMYD88OverallReadDepth") as TextBox).Text;
using (SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["Molecular"].ConnectionString))
{
con.Open();
using (SqlCommand sc = new SqlCommand(@"UPDATE MutationResults
SET TechniqueforMYD88=@TechniqueforMYD88, MYD88ExonsAnalyzed=@MYD88ExonsAnalyzed, SequenceofEntireMYD88=@SequenceofEntireMYD88,
MYD88MutationStatus=@MYD88MutationStatus, NumberofMYD88Mutations=@NumberofMYD88Mutations, MYD88pL265PMutation=@MYD88pL265PMutation,
OtherMYD88MutationDescription=@OtherMYD88MutationDescription, MYD88VAFPercentage=@MYD88VAFPercentage, MYD88RefAllelesReads=@MYD88RefAllelesReads,
MYD88VariantAllelesReads=@MYD88VariantAllelesReads, MYD88OverallReadDepth=@MYD88OverallReadDepth
WHERE
ID=@TestID and SampleBranchID=@SampleBranchID", con))
{
sc.Parameters.AddWithValue("@TestID", TestID.Text);
sc.Parameters.AddWithValue("@SampleBranchID", SampleBranchID.Text);
sc.Parameters.AddWithValue("@TechniqueforMYD88", TechniqueforMYD88);
sc.Parameters.AddWithValue("@MYD88ExonsAnalyzed", MYD88ExonsAnalyzed);
sc.Parameters.AddWithValue("@SequenceofEntireMYD88", SequenceofEntireMYD88);
sc.Parameters.AddWithValue("@MYD88MutationStatus", MYD88MutationStatus);
sc.Parameters.AddWithValue("@NumberofMYD88Mutations", NumberofMYD88Mutations);
sc.Parameters.AddWithValue("@MYD88pL265PMutation", MYD88pL265PMutation);
sc.Parameters.AddWithValue("@OtherMYD88MutationDescription", OtherMYD88MutationDescription);
sc.Parameters.AddWithValue("@MYD88VAFPercentage", MYD88VAFPercentage);
sc.Parameters.AddWithValue("@MYD88RefAllelesReads", MYD88RefAllelesReads);
sc.Parameters.AddWithValue("@MYD88VariantAllelesReads", MYD88VariantAllelesReads);
sc.Parameters.AddWithValue("@MYD88OverallReadDepth", MYD88OverallReadDepth);
sc.ExecuteScalar();
}
con.Close();
}
GridViewMYD88.EditIndex = -1;
this.BindGridMutationResults();
}
任何帮助如何解决此问题。感谢