/* --------------- Jokes --------------------------------------*/ public void UpdateJokes() { SqlConnection conn = new SqlConnection(dbconn.Configuration()); SqlCommand cmd = null; SqlDataReader rdr = null; string sqlsel = "select * from joke"; try { conn.Open(); cmd = new SqlCommand(sqlsel, conn); rdr = cmd.ExecuteReader(); GridViewJokes.DataSource = rdr; GridViewJokes.DataBind(); } catch (Exception ex) { LabelMessage.Text = ex.Message; } finally { conn.Close(); } }
public void UpdateGridviewJokes() { try { UpdateDropdown(); UpdateDropdownCat(); GridViewJokes.DataBind(); } catch (Exception ex) { statusInfo.Text = ex.Message + ex.StackTrace; } finally { conn.Close(); // SqlDataAdapter closes connextion by itself; but can fail in case of errors } }
protected void DetailsViewJokes_ItemInserted(object sender, DetailsViewInsertedEventArgs e) { GridViewJokes.DataBind(); }