//fungsi: menghandle ketika row pada gridview akan di edit, //set fokus pada isian di gridview protected void GvBagian_RowEditing(object sender, GridViewEditEventArgs e) { if (Page.IsValid) { GvBagian.EditIndex = e.NewEditIndex; GvBagian.DataBind(); this.ScriptManager1.SetFocus(GvBagian.Rows[e.NewEditIndex].Cells[1].FindControl("txtCol1Edit").ClientID); } else { e.Cancel = true; } }
//fungsi: pindah halaman/index page dari gridview protected void txtHalaman_TextChanged(object sender, System.EventArgs e) { GridViewRow rowPager = GvBagian.BottomPagerRow; TextBox txtHalaman = (TextBox)(rowPager.Cells[0].FindControl("txtHalaman")); try { if (int.Parse(txtHalaman.Text) <= GvBagian.PageCount + 1 && int.Parse(txtHalaman.Text) > 0) { GvBagian.PageIndex = (int.Parse(txtHalaman.Text)) - 1; GvBagian.DataBind(); } } catch (Exception) { txtHalaman.Text = (GvBagian.PageIndex + 1).ToString(); } }
//fungsi: refresh gridview ketika filter berubah protected void ddlFilterItemChange(object sender, EventArgs e) { doFiltering(); GvBagian.DataBind(); }