Load data into grid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harlem98
    New Member
    • Oct 2021
    • 3

    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 (rdpInvestigado r).

    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

    Code:
    <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.BLLListagemTimesheets" 
                       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>
    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 (rdpInvestigado r).

    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:RadCom boBox ID="rdpInvestig ador" runat="server" EmptyMessage=" - escolher - " AutoPostBack="t rue" EnableLoadOnDem and="true" </telerik:RadComb oBox>
    <telerik:RadBut ton ID="ButtonPerfo rmSearch" Text="Aceder à listagem de timesheets" ValidationGroup ="search" OnClick="Button PerformSearch_C lick"
    runat="server" CssClass="btn btn-mini" Width="50%" ButtonType="Tog gleButton"
    CausesValidatio n="true"></telerik:RadButt on>
    <asp:LinkButt on ID="lkbPesquisa r" runat="server" CssClass="btn btn-mini" OnClick="lkbPes quisar_Click">p esquisar</asp:LinkButton>

    <asp:ObjectData Source ID="DataSourceT imesheets" runat="server" EnablePaging="T rue" OnSelecting="Da taSourceTimeshe ets_Selecting" SortParameterNa me="sortType" TypeName="UMinh o.GestaoProject os.BLL.BLLLista gemTimesheets"
    SelectMethod="G etList" SelectCountMeth od="GetListCoun t">

    <SelectParamete rs>

    <asp:ControlPar ameter ControlID="rdpI nvestigador" Name="IDRecurso Humano" PropertyName="S electedValue" DefaultValue="" Type="Int32" />

    <asp:Paramete r Name="ID" Type="Int32" />

    <asp:Paramete r Name="DataEnvio " Type="datetime" />

    <asp:Paramete r Name="IDEstadoT imesheet" Type="Int32" />

    <asp:Paramete r Name="Assinatur aTimesheet" Type="string" />

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

    <asp:Paramete r Name="Ficheiro" Type="string" />

    <asp:Paramete r Name="FileTipo" Type="string" />

    <asp:Paramete r Name="FileConte nt" Type="Byte" />

    <asp:Paramete r Name="login" Type="String" />


    </SelectParameter s>
    </asp:ObjectDataS ource>

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

    public List<ListagemTi mesheet> GetList(int? ID, int? IDRecursoHumano , DateTime? DataEnvio, string AssinaturaTimes heet,int? IDEstadoTimeshe et, string Observações, string Ficheiro, string FileTipo, byte FileContent, string sortType, int maximumRows, int startRowIndex, string login)
    {
    using (GestaoProjecto sEntities db = new GestaoProjectos Entities())
    {
    var entities = from e in db.ListagemTime sheets
    select e;

    entities = GetQueryList(en tities, ID, IDRecursoHumano , DataEnvio, AssinaturaTimes heet, IDEstadoTimeshe et, Observações, Ficheiro, FileTipo, FileContent, login);

    entities = GetListSort(ent ities.AsQueryab le(), sortType);

    entities.Skip(s tartRowIndex).T ake(maximumRows );

    return entities.ToList ();
    }
    }

    public int GetListCount(in t? ID, int? IDRecursoHumano , DateTime? DataEnvio, string AssinaturaTimes heet,int? IDEstadoTimeshe et, string Observações, string Ficheiro, string FileTipo, byte FileContent, string login)
    {
    using (GestaoProjecto sEntities db = new GestaoProjectos Entities())
    {
    var entities = from e in db.ListagemTime sheets
    select e;

    return GetQueryList(en tities, ID, IDRecursoHumano , DataEnvio, AssinaturaTimes heet, IDEstadoTimeshe et, Observações, Ficheiro, FileTipo, FileContent, login).Count();
    }
    }

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

    Code:
    public Utils.FormMode FormMode
        {
            get { return ViewState["___formmode"] == null ? Utils.FormMode.CreateMode : (Utils.FormMode)ViewState["___formmode"]; }
    
            set { ViewState["___formmode"] = value; }
        }
        //ID
        public int ID
        {
            get { return ViewState["___entitypk"] == null ? 0 : (int)ViewState["___entitypk"]; }
    
            set { ViewState["___entitypk"] = value; }
        }
    
        BLLListagemTimesheets listagembll = new BLLListagemTimesheets();
        BLLPesquisarTimesheet pesquisarbll = new BLLPesquisarTimesheet();
        BLLTemplateFile templatebll = new BLLTemplateFile();
    
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get reference to AjaxManager (from Master) 
            var manager = RadAjaxManager.GetCurrent(Page);
    
            //Create a new delegate to handle the AjaxRequest event 
            //manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(RadAjaxManager1_AjaxRequest);
    
            //Add your ajax settings programmatically (with ref to Master manager) 
            manager.AjaxSettings.AddAjaxSetting(manager, gvTimesheets);
    
            if (Request.QueryString["ID"] != null)
            {
                if (Request.QueryString["action"] != "TemplateFileDownload")
                    DownloadFile(Convert.ToInt32(Request.QueryString["ID"]));
                else
                    ExportFile_Click();
            }
    
            else
            {
                if (!Page.IsPostBack)
                {
                    RecursoHumano rh = new RecursoHumano();
    
                    rdpUnidade.DataValueField = "ID";
                    rdpUnidade.DataTextField = "NomeUnidade";
                    rdpUnidade.DataSource = new BLLUnidades().GetAllCentrosInvestigacao();
                    rdpUnidade.DataBind();
                    //rdpUnidade.ClearSelection();
    
                    // Sem filtros (Nao consigo utilizar o AjaxManager!) // new BLLProjectoEquipa().GetAll()
                    rdpInvestigador.DataSource = new BLLRecursoHumano().GetAll();
                    rdpInvestigador.DataValueField = "ID";
                    rdpInvestigador.DataTextField = "Nome";
                    rdpInvestigador.DataBind();
                    rdpInvestigador.Items.Insert(0, new RadComboBoxItem("", ""));
    
    
                }
            }
          //2 approaches, 1st one
    
          protected void ButtonPerformSearch_Click(object sender, EventArgs e)
        {
            gvTimesheets.Rebind();
        }
    
        protected void rdpInvestigador_SelectedIndexChanged(object sender, EventArgs e)
        {
            gvTimesheets.DataSource = rdpInvestigador.SelectedValue;
            gvTimesheets.Rebind();
        }  
          //Second
    
         protected void lkbPesquisar_Click(object sender, EventArgs e)
        {
            BindInvestigadores();
        }
    
         private void BindInvestigadores() // gvTimesheets.DataBind(); nao dá exception mas nao carrega
        {
      
            gvTimesheets.DataBind();
        }
    After many tries, i have no ideia about what's wrong, does anyone familiar with this?
Working...