private void BindLibrary() { if (CurrentResource != null && !CurrentResource.Match(resourceFilter)) { _currentResourceId = -1; } using (Database dbObj = new Database(SessionState.CacheComponents["DAM_DB"].ConnectionString)) { string sqlQuery = "SELECT * FROM VIEW_DAM_Resources WHERE LibraryId = @LibraryId{0} ORDER BY ResourceName"; sqlQuery = String.Format(sqlQuery, resourceFilter != null ? " AND (ResourceName LIKE '%' + @Filter+ '%' OR ResourceDescription LIKE '%' + @Filter+ '%')" : ""); using (DataSet ds = dbObj.RunSQLReturnDataSet(sqlQuery, Database.NewSqlParameter("@LibraryId", SqlDbType.Int, _currentLibraryId), Database.NewSqlParameter("@Filter", SqlDbType.NVarChar, 500, resourceFilter))) if (ds != null && ds.Tables.Count == 1) { resourcesPagerTop.Visible = resourcesPagerBottom.Visible = resourceGrid.Visible = completePanel.Visible = ds.Tables[0].Rows.Count > 0; resourceGrid.Columns[1].Visible = (DisplayMode != Mode.Complete); completePanel.Visible = completePanel.Visible && DisplayMode == Mode.Complete; resourceGrid.DataSource = ds; if (resourceGrid.CurrentPageIndex * resourceGrid.PageSize > ds.Tables[0].Rows.Count) { resourceGrid.CurrentPageIndex = 0; } if (_currentResourceId >= 0) { ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns[0] }; int index = ds.Tables[0].Rows.IndexOf(ds.Tables[0].Rows.Find(_currentResourceId)); resourceGrid.CurrentPageIndex = (int)Math.Floor((double)index / resourceGrid.PageSize); } resourceGrid.DataBind(); emptyLibPanel.Visible = ds.Tables[0].Rows.Count == 0; if (_currentResourceId < 0 && ds.Tables.Count == 1 && ds.Tables[0].Rows.Count > 0) { _currentResourceId = (int)ds.Tables[0].Rows[0]["ResourceId"]; chooseResource(0); } } } if (_currentResourceId >= 0) { //Response.Write(_currentResourceId + " " + resourceGrid.DataKeys.Count); for (int index = 0; index < resourceGrid.DataKeys.Count; index++) { if ((int)resourceGrid.DataKeys[index] == _currentResourceId) { chooseResource(index); } } } txtResourceTypeValue.DataSource = resourceTypes; resourceTypesAttributes.DataSource = resourceTypes; txtResourceTypeValue.DataBind(); resourceTypesAttributes.DataBind(); if (DisplayMode == Mode.Complete) { BindResource(); } }
private void BindLibrary() { if (CurrentResource != null && !CurrentResource.Match(resourceFilter)) { _currentResourceId = -1; } if (_currentResourceId < 0) { HyperCatalog.Business.DAM.Resource resource = resources.GetByIndex(0); if (resource != null) { _currentResourceId = resource.Id; } } rGd.DataSource = resources; rGd.DataBind(); rGd.Visible = completePanel.Visible = rGd.Rows.Count > 0; emptyLibPanel.Visible = rGd.Rows.Count == 0; if (_currentResourceId >= 0) { UltraGridRow row = null; for (int index = 0; index < rGd.DataKeys.Count; index++) { if ((int)rGd.DataKeys[index] == _currentResourceId) { row = rGd.Rows[index]; } } if (row != null) { row.Selected = true; } } txtResourceTypeValue.DataSource = resourceTypes; resourceTypesAttributes.DataSource = resourceTypes; txtResourceTypeValue.DataBind(); resourceTypesAttributes.DataBind(); if (DisplayMode == Mode.Complete) { BindResource(); } }