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 に答える