// Populate the GridView with data private void BindGrid() { // Get DepartmentID from the query string string departmentId = Request.QueryString["DepartmentID"]; // Get a DataTable object containing the categories grid.DataSource = CatalogBLO.GetCategoriesInDepartment(departmentId); // Bind the data grid to the data source grid.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { // don't reload data during postbacks if (!IsPostBack) { // Obtain the ID of the selected department string departmentId = Request.QueryString["DepartmentID"]; // Continue only if DepartmentID exists in the query string if (departmentId != null) { // Catalog.GetCategoriesInDepartment returns a DataTable object containing // category data, which is displayed by the DataList list.DataSource = CatalogBLO.GetCategoriesInDepartment(departmentId); // Needed to bind the data bound controls to the data source list.DataBind(); // Make space for the next control brLabel.Text = "<br />"; } } }