A continuacion, coloco Codigo:
Del 1° Form:
Código:
protected void GridRol_SelectedIndexChanged(object sender, EventArgs e) { // Se obtiene la fila seleccionada del gridview GridViewRow row = GridRol.SelectedRow; // Obtengo el id de la entidad que se esta editando // en este caso de la entidad Curso ViewState["idRol"] = Convert.ToInt32(GridRol.DataKeys[row.RowIndex].Value); string Id_Rol = row.Cells[1].Text; string Descripcion = row.Cells[2].Text; Response.Redirect("ABMRol.aspx?Id_Rol=" + Id_Rol + "&Descripcion=" + Descripcion); }
Del 2° WebForm:
Código:
protected void ButtonModificar_Click(object sender, EventArgs e) { string cadenaConexion = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; using (OleDbConnection cnn = new OleDbConnection(cadenaConexion)) { cnn.Open(); string query = @"Update Rol Set Descripcion = @Desc Where Id_Rol = @id"; OleDbCommand com = new OleDbCommand(query, cnn); com.Parameters.AddWithValue("@Desc", TextDescripcion.Text); com.Parameters.AddWithValue("@id", ViewState["idRol"]); com.ExecuteScalar(); } }
De esta forma que esta planteado en el 1° web form, me da el sig. Error:
"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
Bueno, necesito probar el codigo a los fines de ver si me Updatea ya que de otras fromas no lo he logrado..
abrazos, nos vemos,...
PERO, de esta otra forma en el 1° WebForm:
Código:
protected void GridRol_SelectedIndexChanged(object sender, EventArgs e) { // Se obtiene la fila seleccionada del gridview GridViewRow row = GridRol.SelectedRow; string Id_Rol = row.Cells[1].Text; string Descripcion = row.Cells[2].Text; Response.Redirect("ABMRol.aspx?Id_Rol=" + Id_Rol + "&Descripcion=" + Descripcion); // Obtengo el id de la entidad que se esta editando // en este caso de la entidad Curso ViewState["idRol"] = Convert.ToInt32(GridRol.DataKeys[row.RowIndex].Value); }
No me da Error, como encabece este Post, pero tampoco me otorga ningun resultado.....
Como se haria para que funcione, si se puede?¡
