private void GetContactEIP() { //FranchisorUserService service = new FranchisorUserService(); //EFranchisorUser[] franchisoruser = service.ContactEIP(); // format phone no. CommonCode objCommonCode = new CommonCode(); FranchisorDAL franchisorDAL = new FranchisorDAL(); var listFranchisorUser = franchisorDAL.ContactEIP(); EFranchisorUser[] franchisoruser = null; if (listFranchisorUser != null) { franchisoruser = listFranchisorUser.ToArray(); } DataTable dtFranchisorUser = new DataTable(); dtFranchisorUser.Columns.Add("Name"); dtFranchisorUser.Columns.Add("Address"); dtFranchisorUser.Columns.Add("Country"); dtFranchisorUser.Columns.Add("PhoneDirect"); dtFranchisorUser.Columns.Add("PhoneOther"); dtFranchisorUser.Columns.Add("Email"); if (franchisoruser != null) { for (int icount = 0; icount < franchisoruser.Length; icount++) { string Name = CommonClass.FormatName(franchisoruser[icount].User.FirstName, "", franchisoruser[icount].User.LastName); string Address = CommonClass.FormatAddress(franchisoruser[icount].User.HomeAddress.Address1, franchisoruser[icount].User.HomeAddress.Address2, franchisoruser[icount].User.HomeAddress.City, franchisoruser[icount].User.HomeAddress.State, franchisoruser[icount].User.HomeAddress.Zip); dtFranchisorUser.Rows.Add(new object[] { Name, Address, franchisoruser[icount].User.HomeAddress.Country, objCommonCode.FormatPhoneNumberGet(franchisoruser[icount].User.PhoneCell), objCommonCode.FormatPhoneNumberGet(franchisoruser[icount].User.PhoneOffice), franchisoruser[icount].User.EMail1 }); } } switch ((SortDirection)ViewState["SortContact"]) { case SortDirection.Descending: dtFranchisorUser.DefaultView.Sort = "name desc"; break; default: dtFranchisorUser.DefaultView.Sort = "name asc"; break; } dtFranchisorUser = dtFranchisorUser.DefaultView.ToTable(); ViewState["DSGRID"] = dtFranchisorUser; gridcontacteip.DataSource = dtFranchisorUser; gridcontacteip.DataBind(); }