473,216 Members | 1,292 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,216 software developers and data experts.

Load data into grid

I'm having serious problems loading data into a grid, i've encountered a number of problems, which i´ve beem solving through different approachs, and now i dont found any issue, but i still cant load the data into the grid. The data is filtered in a external comboBox (rdpInvestigador).

I use a n-layer architecture with ASP Object Data Source. i'm sharing the critical part of the code not to overextend the post.

//HTML

Expand|Select|Wrap|Line Numbers
  1. <telerik:RadComboBox ID="rdpInvestigador" runat="server" EmptyMessage=" - escolher - " AutoPostBack="true"  EnableLoadOnDemand="true"      </telerik:RadComboBox>
  2. <telerik:RadButton ID="ButtonPerformSearch" Text="Aceder à listagem de timesheets" ValidationGroup="search" OnClick="ButtonPerformSearch_Click"
  3.                     runat="server"  CssClass="btn btn-mini"  Width="50%" ButtonType="ToggleButton"
  4.                    CausesValidation="true"></telerik:RadButton>
  5.  <asp:LinkButton ID="lkbPesquisar" runat="server" CssClass="btn btn-mini" OnClick="lkbPesquisar_Click">pesquisar</asp:LinkButton>
  6.  
  7. <asp:ObjectDataSource ID="DataSourceTimesheets" runat="server" EnablePaging="True" OnSelecting="DataSourceTimesheets_Selecting" SortParameterName="sortType" TypeName="UMinho.GestaoProjectos.BLL.BLLListagemTimesheets" 
  8.                    SelectMethod="GetList" SelectCountMethod="GetListCount">
  9.  
  10.                     <SelectParameters>
  11.  
  12.                          <asp:ControlParameter ControlID="rdpInvestigador" Name="IDRecursoHumano" PropertyName="SelectedValue" DefaultValue="" Type="Int32" />
  13.  
  14.                          <asp:Parameter  Name="ID"  Type="Int32" />
  15.  
  16.                         <asp:Parameter  Name="DataEnvio"  Type="datetime"  />
  17.  
  18.                          <asp:Parameter  Name="IDEstadoTimesheet"  Type="Int32" />
  19.  
  20.                          <asp:Parameter  Name="AssinaturaTimesheet"  Type="string" />
  21.  
  22.                           <asp:Parameter  Name="Observações"  Type="string" />
  23.  
  24.                           <asp:Parameter  Name="Ficheiro"  Type="string" />
  25.  
  26.                           <asp:Parameter  Name="FileTipo"  Type="string" />
  27.  
  28.                          <asp:Parameter  Name="FileContent" Type="Byte"   />
  29.  
  30.                         <asp:Parameter Name="login" Type="String" />
  31.  
  32.  
  33.                     </SelectParameters>
  34.                 </asp:ObjectDataSource>
I'm having serious problems loading data into a grid, i've encountered a number of problems, which i´ve beem solving through different approachs, and now i dont found any issue, but i still cant load the data into the grid. The data is filtered in a external comboBox (rdpInvestigador).

I use a n-layer architecture with ASP Object Data Source. i'm sharing the critical part of the code not to overextend the post

//HTML

<telerik:RadComboBox ID="rdpInvestigador" runat="server" EmptyMessage=" - escolher - " AutoPostBack="true" EnableLoadOnDemand="true" </telerik:RadComboBox>
<telerik:RadButton ID="ButtonPerformSearch" Text="Aceder à listagem de timesheets" ValidationGroup="search" OnClick="ButtonPerformSearch_Click"
runat="server" CssClass="btn btn-mini" Width="50%" ButtonType="ToggleButton"
CausesValidation="true"></telerik:RadButton>
<asp:LinkButton ID="lkbPesquisar" runat="server" CssClass="btn btn-mini" OnClick="lkbPesquisar_Click">pesquisar</asp:LinkButton>

<asp:ObjectDataSource ID="DataSourceTimesheets" runat="server" EnablePaging="True" OnSelecting="DataSourceTimesheets_Selecting" SortParameterName="sortType" TypeName="UMinho.GestaoProjectos.BLL.BLLListagemTi mesheets"
SelectMethod="GetList" SelectCountMethod="GetListCount">

<SelectParameters>

<asp:ControlParameter ControlID="rdpInvestigador" Name="IDRecursoHumano" PropertyName="SelectedValue" DefaultValue="" Type="Int32" />

<asp:Parameter Name="ID" Type="Int32" />

<asp:Parameter Name="DataEnvio" Type="datetime" />

<asp:Parameter Name="IDEstadoTimesheet" Type="Int32" />

<asp:Parameter Name="AssinaturaTimesheet" Type="string" />

<asp:Parameter Name="Observações" Type="string" />

<asp:Parameter Name="Ficheiro" Type="string" />

<asp:Parameter Name="FileTipo" Type="string" />

<asp:Parameter Name="FileContent" Type="Byte" />

<asp:Parameter Name="login" Type="String" />


</SelectParameters>
</asp:ObjectDataSource>

//BLL method, used in object data source (wanted data that not load is "listagem timesheet"

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)
{
using (GestaoProjectosEntities db = new GestaoProjectosEntities())
{
var entities = from e in db.ListagemTimesheets
select e;

entities = GetQueryList(entities, ID, IDRecursoHumano, DataEnvio, AssinaturaTimesheet, IDEstadoTimesheet, Observações, Ficheiro, FileTipo, FileContent, login);

entities = GetListSort(entities.AsQueryable(), sortType);

entities.Skip(startRowIndex).Take(maximumRows);

return entities.ToList();
}
}

public int GetListCount(int? ID, int? IDRecursoHumano, DateTime? DataEnvio, string AssinaturaTimesheet,int? IDEstadoTimesheet, string Observações, string Ficheiro, string FileTipo, byte FileContent, string login)
{
using (GestaoProjectosEntities db = new GestaoProjectosEntities())
{
var entities = from e in db.ListagemTimesheets
select e;

return GetQueryList(entities, ID, IDRecursoHumano, DataEnvio, AssinaturaTimesheet, IDEstadoTimesheet, Observações, Ficheiro, FileTipo, FileContent, login).Count();
}
}

// Cs class, with 2 approachs managed by the 2 buttons

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.     BLLPesquisarTimesheet pesquisarbll = new BLLPesquisarTimesheet();
  17.     BLLTemplateFile templatebll = new BLLTemplateFile();
  18.  
  19.     protected void Page_Load(object sender, EventArgs e)
  20.     {
  21.         //Get reference to AjaxManager (from Master) 
  22.         var manager = RadAjaxManager.GetCurrent(Page);
  23.  
  24.         //Create a new delegate to handle the AjaxRequest event 
  25.         //manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(RadAjaxManager1_AjaxRequest);
  26.  
  27.         //Add your ajax settings programmatically (with ref to Master manager) 
  28.         manager.AjaxSettings.AddAjaxSetting(manager, gvTimesheets);
  29.  
  30.         if (Request.QueryString["ID"] != null)
  31.         {
  32.             if (Request.QueryString["action"] != "TemplateFileDownload")
  33.                 DownloadFile(Convert.ToInt32(Request.QueryString["ID"]));
  34.             else
  35.                 ExportFile_Click();
  36.         }
  37.  
  38.         else
  39.         {
  40.             if (!Page.IsPostBack)
  41.             {
  42.                 RecursoHumano rh = new RecursoHumano();
  43.  
  44.                 rdpUnidade.DataValueField = "ID";
  45.                 rdpUnidade.DataTextField = "NomeUnidade";
  46.                 rdpUnidade.DataSource = new BLLUnidades().GetAllCentrosInvestigacao();
  47.                 rdpUnidade.DataBind();
  48.                 //rdpUnidade.ClearSelection();
  49.  
  50.                 // Sem filtros (Nao consigo utilizar o AjaxManager!) // new BLLProjectoEquipa().GetAll()
  51.                 rdpInvestigador.DataSource = new BLLRecursoHumano().GetAll();
  52.                 rdpInvestigador.DataValueField = "ID";
  53.                 rdpInvestigador.DataTextField = "Nome";
  54.                 rdpInvestigador.DataBind();
  55.                 rdpInvestigador.Items.Insert(0, new RadComboBoxItem("", ""));
  56.  
  57.  
  58.             }
  59.         }
  60.       //2 approaches, 1st one
  61.  
  62.       protected void ButtonPerformSearch_Click(object sender, EventArgs e)
  63.     {
  64.         gvTimesheets.Rebind();
  65.     }
  66.  
  67.     protected void rdpInvestigador_SelectedIndexChanged(object sender, EventArgs e)
  68.     {
  69.         gvTimesheets.DataSource = rdpInvestigador.SelectedValue;
  70.         gvTimesheets.Rebind();
  71.     }  
  72.       //Second
  73.  
  74.      protected void lkbPesquisar_Click(object sender, EventArgs e)
  75.     {
  76.         BindInvestigadores();
  77.     }
  78.  
  79.      private void BindInvestigadores() // gvTimesheets.DataBind(); nao dá exception mas nao carrega
  80.     {
  81.  
  82.         gvTimesheets.DataBind();
  83.     }
After many tries, i have no ideia about what's wrong, does anyone familiar with this?
Oct 18 '21 #1
0 3666

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: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.