protected void BindGrid() { try { if (hdnCurrentPage.Value.ToString() != "") { mypager.CurrentPage = Int32.Parse(hdnCurrentPage.Value.ToString()); hdnCurrentPage.Value = ""; } advisorVo = (AdvisorVo)Session["advisorVo"]; int Count; if (Session["Branch"] != null) { lblMessage.Visible = false; string branch = Session["Branch"].ToString(); if (branch.ToLower().Trim() == "find branch" || branch.ToLower().Trim() == "") { branch = ""; } branchList = advisorBranchBo.FindBranch(branch, advisorVo.advisorId, mypager.CurrentPage, hdnSort.Value, out Count); lblTotalRows.Text = hdnCount.Value = Count.ToString(); LoadBranches(branchList); Session.Remove("Branch"); } else { advisorBranchList = advisorBranchBo.GetAdvisorBranches(advisorVo.advisorId, hdnSort.Value, mypager.CurrentPage, out Count); lblTotalRows.Text = hdnCount.Value = Count.ToString(); //if (Count > 0) //{ // tblPager.Visible = true; // lblTotalRows.Text = hdnCount.Value = Count.ToString(); //} if (advisorBranchList.Count == 0) { lblMessage.Visible = true; tblPager.Visible = false; lblCurrentPage.Visible = false; lblTotalRows.Visible = false; } else { lblMessage.Visible = false; DataTable dtAdvisorBranch2 = new DataTable(); dtAdvisorBranch2.Columns.Add("Sl.No."); dtAdvisorBranch2.Columns.Add("BranchId"); dtAdvisorBranch2.Columns.Add("BranchName"); dtAdvisorBranch2.Columns.Add("BranchCode"); dtAdvisorBranch2.Columns.Add("Email"); dtAdvisorBranch2.Columns.Add("Phone"); dtAdvisorBranch2.Columns.Add("BranchHead"); dtAdvisorBranch2.Columns.Add("BranchType"); DataRow drAdvisorBranch; for (int i = 0; i < advisorBranchList.Count; i++) { drAdvisorBranch = dtAdvisorBranch2.NewRow(); advisorBranchVo = new AdvisorBranchVo(); advisorBranchVo = advisorBranchList[i]; drAdvisorBranch[0] = (i + 1).ToString(); drAdvisorBranch[1] = advisorBranchVo.BranchId.ToString(); drAdvisorBranch[2] = advisorBranchVo.BranchName.ToString(); drAdvisorBranch[3] = advisorBranchVo.BranchCode.ToString(); drAdvisorBranch[4] = advisorBranchVo.Email; drAdvisorBranch[5] = advisorBranchVo.Phone1Isd.ToString() + "-" + advisorBranchVo.Phone1Std.ToString() + "-" + advisorBranchVo.Phone1Number.ToString(); drAdvisorBranch[6] = advisorBranchVo.BranchHead.ToString(); drAdvisorBranch[7] = advisorBranchVo.BranchType.ToString(); dtAdvisorBranch2.Rows.Add(drAdvisorBranch); } gvBranchList.DataSource = dtAdvisorBranch2; gvBranchList.DataBind(); gvBranchList.Visible = true; } } this.GetPageCount(); } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "ViewBranches.ascx:Page_Load()"); object[] objects = new object[4]; objects[0] = advisorVo; objects[1] = advisorBranchVo; objects[2] = advisorBranchBo; objects[3] = advisorBranchList; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } }