473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Load data into grid

I'm having huge problems loading data into a grid. i've encountered a number of problems, which i´ve been solving through different approachs, and now i dont have any exception, but i still cant load the data into the grid.

The data is filtered according to "rdpInvestigador" external selectedValue, and should load in the grid accordingly.

I use a n-layer architecture and ASP ObjectDataSource to Bind DB.

I will put the main parts of the code, in order to be possible to understand and find the issue. I will also attach an image with the appearence of the system.

I believe the problem is on CS code, but it could also be on the BLL "GetList" method.

// HTML

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.   function refreshGrid(arg) {
  3.   var radManager = $find('<%=
  4.   RadAjaxManager.GetCurrent(Page).ClientID %>');
  5.   if (!arg) {
  6.    radManager.ajaxRequest("Rebind");
  7.   }
  8.     else {
  9.    radManager.ajaxRequest(arg);
  10.             }
  11.    }
  12.  
  13. function myUserControlClickHandler() {
  14. $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("FromUserControl");                       }
  15.  </script>
  16.  
  17. <telerik:RadComboBox ID="rdpInvestigador" </telerik:RadComboBox>
  18.  
  19. <telerik:RadButton ID="ButtonPerformSearch" Text="Aceder à listagem de timesheets" ValidationGroup="search" OnClick="ButtonPerformSearch_Click"
  20.                     runat="server"  CssClass="btn btn-mini"  Width="50%" ButtonType="ToggleButton"
  21.                    CausesValidation="true"></telerik:RadButton>
  22.  <asp:LinkButton ID="lkbPesquisar" runat="server" CssClass="btn btn-mini" OnClick="lkbPesquisar_Click">pesquisar</asp:LinkButton>
  23.  
  24. <telerik:RadGrid ID="gvTimesheets" DataSourceID="DataSourceTimesheets" OnSelectedIndexChanged="rdpInvestigador_SelectedIndexChanged" OnItemCommand="gvTimesheets_ItemCommand"
  25.  
  26. <asp:ObjectDataSource ID="DataSourceTimesheets" runat="server" EnablePaging="True" OnSelecting="DataSourceTimesheets_Selecting" SortParameterName="sortType" TypeName="UMinho.GestaoProjectos.BLL.BLLListagemTimesheets"
  27.                    SelectMethod="GetList" SelectCountMethod="GetListCount">
  28.                     <SelectParameters>
  29.                          <asp:ControlParameter ControlID="rdpInvestigador" Name="IDRecursoHumano" PropertyName="SelectedValue" DefaultValue="" Type="Int32" />
  30.                          <asp:Parameter  Name="ID"  Type="Int32" />
  31.                         <asp:Parameter  Name="DataEnvio"  Type="datetime"  />
  32.                          <asp:Parameter  Name="IDEstadoTimesheet"  Type="Int32" />
  33.                          <asp:Parameter  Name="AssinaturaTimesheet"  Type="string" />
  34.                           <asp:Parameter  Name="Observações"  Type="string" />
  35.                          <asp:Parameter  Name="Ficheiro"  Type="string" />
  36.                           <asp:Parameter  Name="FileTipo"  Type="string" />
  37.                          <asp:Parameter  Name="FileContent" Type="Byte"   />
  38.                         <asp:Parameter Name="login" Type="String" />
  39.  
  40.                     </SelectParameters>
  41.                 </asp:ObjectDataSource>
//BLL method, used in object data source (wanted data that not load is "listagem timesheet"

Expand|Select|Wrap|Line Numbers
  1. public List<ListagemTimesheet> GetList(int? ID, int? IDRecursoHumano, DateTime? DataEnvio, string AssinaturaTimesheet,int? IDEstadoTimesheet, string Observações, string Ficheiro, string FileTipo, byte FileContent, string sortType, int maximumRows, int startRowIndex, string login)
  2.   {
  3.       using (GestaoProjectosEntities db = new GestaoProjectosEntities())
  4.       {
  5.           var entities = from e in db.ListagemTimesheets
  6.                          select e;
  7.  
  8.           entities = GetQueryList(entities, ID, IDRecursoHumano, DataEnvio, AssinaturaTimesheet, IDEstadoTimesheet, Observações, Ficheiro, FileTipo, FileContent, login);
  9.  
  10.           entities = GetListSort(entities.AsQueryable(), sortType);
  11.  
  12.           entities.Skip(startRowIndex).Take(maximumRows);
  13.  
  14.           return entities.ToList();
  15.       }
  16.   }
  17.  
  18.        public int GetListCount(int? ID, int? IDRecursoHumano, DateTime? DataEnvio, string AssinaturaTimesheet,int? IDEstadoTimesheet, string Observações, string Ficheiro, string FileTipo, byte FileContent, string login)
  19.        {
  20.            using (GestaoProjectosEntities db = new GestaoProjectosEntities())
  21.            {
  22.                var entities = from e in db.ListagemTimesheets
  23.                               select e;
  24.  
  25.                return GetQueryList(entities, ID, IDRecursoHumano, DataEnvio, AssinaturaTimesheet, IDEstadoTimesheet, Observações, Ficheiro, FileTipo, FileContent, login).Count();
  26.            }
  27.        }
// Cs class, with 3 approachs: 1-FormsMode; 2-OnSelectedIndex(); 3-DataBind()

Expand|Select|Wrap|Line Numbers
  1. public Utils.FormMode FormMode
  2.     {
  3.         get { return ViewState["___formmode"] == null ? Utils.FormMode.CreateMode : (Utils.FormMode)ViewState["___formmode"]; }
  4.  
  5.         set { ViewState["___formmode"] = value; }
  6.     }
  7.     //ID
  8.     public int ID
  9.     {
  10.         get { return ViewState["___entitypk"] == null ? 0 : (int)ViewState["___entitypk"]; }
  11.  
  12.         set { ViewState["___entitypk"] = value; }
  13.     }
  14.  
  15.     BLLListagemTimesheets listagembll = new BLLListagemTimesheets();
  16.  
  17.     protected void Page_Load(object sender, EventArgs e)
  18.     {
  19.         //Get reference to AjaxManager (from Master)
  20.         var manager = RadAjaxManager.GetCurrent(Page);
  21.  
  22.         //Create a new delegate to handle the AjaxRequest event
  23.         //manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(RadAjaxManager1_AjaxRequest);
  24.  
  25.         //Add your ajax settings programmatically (with ref to Master manager)
  26.         manager.AjaxSettings.AddAjaxSetting(manager, gvTimesheets);
  27.  
  28.         if (Request.QueryString["ID"] != null)
  29.         {
  30.             if (Request.QueryString["action"] != "TemplateFileDownload")
  31.                 DownloadFile(Convert.ToInt32(Request.QueryString["ID"]));
  32.             else
  33.                 ExportFile_Click();
  34.         }
  35.  
  36.         else
  37.         {
  38.             if (!Page.IsPostBack)
  39.             {
  40.                 RecursoHumano rh = new RecursoHumano();
  41.  
  42.                 rdpInvestigador.DataSource = new BLLRecursoHumano().GetAll();
  43.                 rdpInvestigador.DataValueField = "ID";
  44.                 rdpInvestigador.DataTextField = "Nome";
  45.                 rdpInvestigador.DataBind();
  46.                 rdpInvestigador.Items.Insert(0, new RadComboBoxItem("", ""));
  47.  
  48.             }
  49.         }
  50.       //2 approaches, 1st one
  51.  
  52.       protected void ButtonPerformSearch_Click(object sender, EventArgs e)
  53.     {
  54.         gvTimesheets.Rebind();
  55.     }
  56.  
  57.     protected void rdpInvestigador_SelectedIndexChanged(object sender, EventArgs e)
  58.     {
  59.         gvTimesheets.DataSource = rdpInvestigador.SelectedValue;
  60.         gvTimesheets.Rebind();
  61.     }
  62.       //Second
  63.  
  64.      protected void lkbPesquisar_Click(object sender, EventArgs e)
  65.     {
  66.         BindInvestigadores();
  67.     }
  68.  
  69.      private void BindInvestigadores() // gvTimesheets.DataBind(); nao dá exception mas nao carrega
  70.     {
  71.  
  72.         gvTimesheets.DataBind();
  73.     }

Oct 19 '21 #1
0 10244

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Snake | last post by:
I have a vb .net program which fills a data grid upon form load from an acccess database. This works great. Now, I have to add a combo box and use it to alter the underlying sql statement and...
1
by: atif | last post by:
i m using webmatrix n i hav a prob with editable data grid. i hav set the data grid with to 100% when i load the page the data grid fits into the screen 100%. but when i clicked on add new or on...
6
by: Tejpal Garhwal | last post by:
I have datagrid filled with some data rows. At the run time i want know how many total rows are there in the data grid ? Any idea ? Any Suggestions ? Thanks in advance Tej
0
by: Gian Paolo | last post by:
this is something really i can't find a reason. I have a form with a tabcontrol with tree pages, in the second page there is a Data GRid View. Plus i have a class. When i open the form i...
2
by: jvdub22 | last post by:
I am currently using a VB 6 MS Data Grid Control bound to an SQL express data base. My grid has 20 visible rows when I load my form, when I scroll down and select a row higher than 20 the grid refers...
0
by: sumaira_it | last post by:
Hi I am building window forms application. i have made a design time data grid. I populated the data grid on form load by fill method of adapter (Where Column1 = 1). I want that when i click on...
0
by: Rasika WIJAYARATNE | last post by:
Hi everyone, I have two grid-views and I am trying to populate the data on gv2 based on the selection in gv1. However when a row is selected in gv1, it doesn't populate the gv2 with data. I have...
0
by: newsaboutgod | last post by:
I am loading a dataset from a XML file. I want to allow the user to display data from the dataset in a grid. Depending on which button they click i want to load the grid with a subset of data...
3
by: vibhakhushi | last post by:
Hi, I'm trying to load data to my grid panel which resides in php using JsonStore object. But the problem is JsonStore is not getting data from php only. Can anyone tell me where i've gone wrong. Is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.