protected void btnthem_Click(object sender, EventArgs e) { SqlDataSource_dsdanhmuc.InsertParameters["TenDanhMuc"].DefaultValue = txtten.Text; try{ SqlDataSource_dsdanhmuc.Insert(); txtten.Text = ""; GridView_dsdanhmuc.DataBind(); lblthongbao.Text = ""; } catch (Exception ex) { lblthongbao.Text = "có lỗi khi thêm dữ liệu.<br/>" + "Message:" + ex.Message; } }
protected void GridView_dsdanhmuc_RowUpdated(object sender, GridViewUpdatedEventArgs e) { GridView_dsdanhmuc.DataBind(); if (GridView_dsdanhmuc.Rows.Count <= 0) { lblthongbao.Text = "Danh sách tài khoản trống!"; } else { lblthongbao.Text = ""; } if (e.Exception != null) { lblthongbao.Text = "Có lỗi xảy ra khi sửa tài khoản!"; e.ExceptionHandled = true; } }