0

:: RowIndex 上的错误未找到

GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];

下面是网格行更新事件......

  protected void GridView1_RowUpdating(object sender, EventArgs e)  
  {         
    GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
    DropDownList ct = (DropDownList)row.FindControl("case_type");
    DropDownList cs = (DropDownList)row.FindControl("case_status");

    con.Open();
    SqlCommand cmd = new SqlCommand("UPDATE intakesheet SET case_number = @case_number, case_name=@case_name, Case_Type=@case_type, Case_Status = @case_status, assigned_date = @assigned_date, assigned_to = @assigned_to, date_withdrawn= @date_withdrawn, date_delivered= @date_delivered, qc_by = @qc_by,  qc_date=@qc_date, additional_notes = @additional_notes WHERE (case_number = @case_number)", con);
    cmd.ExecuteNonQuery();
    GridView1.EditIndex = -1;
    con.Close();
    bind();

}

public void bind()
{

    con.Open();
    SqlDataAdapter da = new SqlDataAdapter("select * from intakesheet", con);
    DataSet ds = new DataSet();
    da.Fill(ds, "intakesheet");
    GridView1.DataSource = ds.Tables[0].DefaultView;
    GridView1.DataBind();
    con.Close();

}
4

1 回答 1

3

更改此行

 protected void GridView1_RowUpdating(object sender, EventArgs e)

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
于 2013-07-31T10:29:03.640 回答