//Show data in the datagrid private void BindData() { CatId = (int)Util.Val(Request.QueryString["catid"]); Tab = (int)Util.Val(Request.QueryString["tab"]); Letter = Request.QueryString["l"]; Find = Request.QueryString["find"]; Top = (int)Util.Val(Request.QueryString["top"]); Month = (int)Util.Val(Request.QueryString["month"]); Year = (int)Util.Val(Request.QueryString["year"]); RecipeImage = (int)Util.Val(Request.QueryString["img"]); LastViewed = (int)Util.Val(Request.QueryString["lv"]); //Set default pageindex and pagesize to pass to the BLL int PageIndex = dgrd_recipe.CurrentPageIndex + 1; int PageSize = Convert.ToInt32(LstRecpage.SelectedItem.Value); //Get pagesize from the pagesize dropdown menu dgrd_recipe.PageSize = PageSize; //Return datatable with custom paging SQL Row_Number. DataTable dt = FetchData.AdminRecipeManagerWithCustomPaging(CatId, Letter, Find, Tab, Top, Year, Month, RecipeImage, LastViewed, PageIndex, PageSize); //Assign datatable to new DataView object DataView dv = new DataView(dt); try { DataRow dr = dt.Rows[0]; if (Top == 100) { //100 Most popular recipe by hits count dgrd_recipe.VirtualItemCount = 100; } else { //Assigned Total records count to grid virtual count dgrd_recipe.VirtualItemCount = (int)dr["RCount"]; } //Initialize variable for total record count to get record count for filter int TotalRecordsCount = (int)dr["RCount"]; //Release datarow object in memory dr = null; //Sort by recipe ID if (lbOrderBy.Text == "") { dv.Sort = "ID"; } else { try { dv.Sort = lbOrderBy.Text + " " + lbDesc.Text; } catch { dv.Sort = "ID"; } } //Assign dataview to grid datasource dgrd_recipe.DataSource = dv; //Bind the data dgrd_recipe.DataBind(); //For Alphabet Letter if (!string.IsNullOrEmpty(Letter)) { lblSortedCat.Text = "There are " + TotalRecordsCount + " recipes starting with letter <b>" + Letter + "</b>"; lblrcdalphaletterfooter.Text = TotalRecordsCount + " recipes starting with letter <b>" + Letter + "</b> -"; lblrcdCatcount.Visible = false; } //For search if (!string.IsNullOrEmpty(Find)) { lblSortedCat.Text = "Your search for recipe name " + "(<b>" + Find + "</b>) return: " + TotalRecordsCount + " records"; lblrcdCatcount.Visible = false; } //For top 100 recipe if (Top == 100) { lblSortedCat.Text = "Top " + 100 + " popular recipes by hits"; lblrcdCatcount.Visible = false; } //For year and month recipe submission if (!string.IsNullOrEmpty(Request.QueryString["year"]) && !string.IsNullOrEmpty(Request.QueryString["month"])) { lblSortedCat.Text = "There are " + TotalRecordsCount + " recipes submitted on " + Utility.GetMonthName(Month) + ", " + Year; lblrcdCatcount.Visible = false; } //Waiting for approval if (Tab == 1) { //Hide the footer total records count LblPageInfo.Visible = false; lblrecordperpageFooter.Visible = false; lblrecordperpageTop.Visible = false; approvallink.Enabled = false; lblSortedCat.Text = "How To? - To approve a recipe, click the Recipe Name link inside the grid."; lblthese.Text = "There are "; lblthese2.Text = TotalRecordsCount + " recipe(s) waiting for approval."; lblmangermainpage.Text = "Recipe Manager Main"; lblmangermainpagelink.ToolTip = "Back to Main Recipe Manager Page"; lblunapproved2.Visible = true; } //Filter for images if (RecipeImage == 1) { lblSortedCat.Text = "There are " + TotalRecordsCount + " recipe with photo"; lblrcdCatcount.Visible = false; } //Filter for lastviewed if (LastViewed > 0) { lblSortedCat.Text = "There are " + TotalRecordsCount + " recipes viewed " + lastviewedlabel; lblrcdCatcount.Visible = false; } //Filter top 100 recipes if (Top == 100) { LblPageInfoTop.Text = "Total Records: 100 - Showing Page: <b>" + PageIndex.ToString() + "</b> of <b>" + dgrd_recipe.PageCount.ToString() + "</b> - Displaying: <b>" + Convert.ToInt32(LstRecpage.SelectedItem.Value) + "</b> Records Per Page"; lblrcdCatcountfooter.Text = "Total Records: 100"; } else { LblPageInfoTop.Text = "Total Records: " + string.Format("{0:#,###}", TotalRecordsCount) + " - Showing Page: <b>" + PageIndex.ToString() + "</b> of <b>" + dgrd_recipe.PageCount.ToString() + "</b> - Displaying: <b>" + Convert.ToInt32(LstRecpage.SelectedItem.Value) + "</b> Records Per Page"; lblrcdCatcountfooter.Text = "Total records: " + string.Format("{0:#,###}", TotalRecordsCount); } lblrcdCatcount.Text = "There are " + string.Format("{0:#,###}", TotalRecordsCount) + " recipes including unapproved recipes"; //Display the pagecount in the top and footer LblPageInfo.Text = "Showing Page: <b>" + PageIndex.ToString() + "</b> of <b>" + dgrd_recipe.PageCount.ToString() + "</b> - Displaying: <b>" + Convert.ToInt32(LstRecpage.SelectedItem.Value) + "</b> Records Per Page" + " - "; } catch { } //Lets hide some unneeded control lblrecordperpageFooter.Visible = false; lblrecordperpageTop.Visible = false; //Release datatable allocated memory dt = null; EnabledDisabled_PagerButtons(); }