RadGrid NeedDataSource Page load

16 posts, 0 answers
  1. Ashwin Deshpande
    Ashwin Deshpande avatar
    31 posts
    Member since:
    Aug 2009

    Posted 02 Sep 2009 Link to this post

    I do not want the RadGrid NeedDataSource to fire on Page Load Event instead i need to fire it on Search button Clickin My Form.
    i need to Populate radgrid only after the input Control Data and Search button Click.
    Please Help me...
    are there any properties i am missing on??

    Regards,
    Ashwin
  2. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 02 Sep 2009 Link to this post

    Ashwin,

    Instead of populating the RadGrid on the NeedDataSource event, you could try assigning the DataSource in the Click event of your Search button.

    protected void Button_Click(object sender, EventArgs e)  
        {  
            RadGrid1.DataSourceID = "DataSourceName";  
        } 

    Casey
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 02 Sep 2009 Link to this post

    Hi Ashwin,

    You do not have use NeedDataSource advanced data-binding if you do not want - you can use simple data binding.

    Regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Ashwin Deshpande
    Ashwin Deshpande avatar
    31 posts
    Member since:
    Aug 2009

    Posted 02 Sep 2009 Link to this post

    Thanks for your reply,
    But the Problem is that i Do Not want need datasource Event to be fired on Page load....By default while debugging after page load it goes to Needatasource code and executes the code.

    Regards,
    Ashwin
  6. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 02 Sep 2009 Link to this post

    Have you tried removing the below from the definition of the RadGrid? If your RadGrid still has a method attached to the OnNeedDataSource event, then it will execute the code. If you remove the OnNeedDataSource event from the RadGrid definition, no code should be executed.

    OnNeedDataSource

     

    ="NeedDataSource"

     

  7. Ashwin Deshpande
    Ashwin Deshpande avatar
    31 posts
    Member since:
    Aug 2009

    Posted 02 Sep 2009 Link to this post

    Below is my Telerik Definition still it goes to NeedDatasource event

    telerik

     

    :RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True"

     

     

    Skin="Office2007" AllowFilteringByColumn="True" ShowStatusBar="True" PageSize="12"

     

     

    Width="99%" >

     

     

    <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true" />

     

     

    <MasterTableView DataKeyNames="ACT_ID" EditMode="PopUp" AutoGenerateColumns="False"

     

     

    Width="100%" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add New Activity">

     

     

    <CommandItemTemplate>

     

     

    <table width="100%">

     

     

    <tr>

     

     

    <td style="text-align: left; width: 30%">

     

     

    <img style="border: 0px" alt="" src="../../Images/Telerik%20Images/AddRecord.gif" />

     

     

    <asp:LinkButton ID="btnAdd" Text="Add New Activity" CommandName="InitInsert" runat="server">

     

     

     

    </asp:LinkButton>

     

     

    </td>

     

     

    <td style="text-align: center; width: 40%">

     

     

    <asp:LinkButton runat="server" ID="LinkButton1" Text="Clear Filters" CommandName="ClearFilters" />

     

     

    </td>

     

     

    <td style="text-align: left; width: 30%">

     

     

    <img style="border: 0px" alt="" src="../../Images/Telerik%20Images/Refresh.gif" />

     

     

    <asp:LinkButton ID="btnRefresh" Text="Refresh" CommandName="Rebind" runat="server">

     

     

    </asp:LinkButton>

     

     

    </td>

     

     

    </tr>

     

     

    </table>

     

     

     

    </CommandItemTemplate>

     

  8. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 02 Sep 2009 Link to this post

    Do you have any code in your Page Load javascript function or Page Load in the codebehind that would fire the OnNeedDataSource event? If not, have you tried removing the code that you don't want executed to see if any errors are generated? Or instead of removing the code, move it into the method called by the OnClick event of the Search button and comment out the code that is being called during Page Load.

    Casey
  9. Ashwin Deshpande
    Ashwin Deshpande avatar
    31 posts
    Member since:
    Aug 2009

    Posted 02 Sep 2009 Link to this post

    I removed everything from the Page Load even then also it goes to Radgrid NeedDataSource Command Event...
  10. Ashwin Deshpande
    Ashwin Deshpande avatar
    31 posts
    Member since:
    Aug 2009

    Posted 02 Sep 2009 Link to this post

    Take this Sample Code ..Even in this One also it goes to NeedDatasource event on page load.Please Suggest

    aspx

    <%

    @ Page Language="VB" AutoEventWireup="false" CodeFile="RadGrid.aspx.vb" Inherits="RadGrid" %>

     

    <%

    @ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

     

    <!

     

    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

     

    <

     

    html xmlns="http://www.w3.org/1999/xhtml">

     

    <

     

    head runat="server">

     

     

    <title>Untitled Page</title>

     

    </

     

    head>

     

    <

     

    body>

     

     

    <form id="form1" runat="server">

     

     

    <div>

     

     

    <telerik:RadGrid ID="RadGrid1" runat="server">

     

     

    </telerik:RadGrid>

     

     

    </div>

     

     

    </form>

     

    </

     

    body>

     

    </

     

    html>

     



    Code:

    Partial

     

    Class RadGrid

     

     

    Inherits System.Web.UI.Page

     

     

    Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource

     

     

    End Sub

     

    End

     

    Class

     

  11. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 02 Sep 2009 Link to this post

    Ashwin,

    Try placing the below in the code exectued by the NeedDataSource event and put a break point on it. Hovering over the RebindReason part should tell you the reason why the NeedDataSource event is firing.

    string reason = e.RebindReason.ToString();     
     

    Could you please paste the method that is called during page load that is giving you issues, as well as the value found in RebindReason?

    Thanks,
    Casey
  12. Ashwin Deshpande
    Ashwin Deshpande avatar
    31 posts
    Member since:
    Aug 2009

    Posted 02 Sep 2009 Link to this post

    On Page Load i am not called any method directly method

    Partial

     

    Class RadGrid

     

     

    Inherits System.Web.UI.Page

     

     

     

     

    Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource

     

     

    Dim str As String = e.RebindReason

     

     

    End Sub

     

    End

     

    Class

     



    e.RebindReason is Coming as InitialLoad
  13. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 02 Sep 2009 Link to this post

    Have you tried removing the below and/or recreating your RadGrid?

    Protected Sub RadGrid1_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource   
     
      Dim str As String = e.RebindReason   
     
    End Sub 
     
  14. Ashwin Deshpande
    Ashwin Deshpande avatar
    31 posts
    Member since:
    Aug 2009

    Posted 02 Sep 2009 Link to this post

    Atlast its fixed..

     

    If e.RebindReason <> GridRebindReason.InitialLoad Then

     


    End if

    In the needDataSource event  i applied the above condition and managed to Skip the database Call.......
  15. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 02 Sep 2009 Link to this post

    That is good that you are now able to avoid that initial binding, but it still doesn't answer why the NeedDataSource event was firing when you didn't have the event specified and were not calling it during the PageLoad.

    Maybe Telerik will have an idea as to why.

    Casey
  16. Dennis
    Dennis avatar
    15 posts
    Member since:
    Feb 2009

    Posted 24 Nov 2009 Link to this post

    Ashwin,

    It sounds like you finally have a resolution; however, your original
    scenario appeared to be you wanted a user search page to come
    up and then the grid (search results) would not be loaded until the
    user clicked  a button (search/find).

    A simple resolution that I often use is to implement a SQL
    statement that evaluates to an empty dataset, object list, etc.
    For example if I am searching a table (MyTable) with primary key
    (MyId), I might create a SQL statement for a SQLDataSource such
    as (Select columns From MyTable Where MyId=-1).  This can be
    done declaratively or programmatically in some middle layer.  Since
    the SQL is going against the primary key in a single table the
    performance is always very good.

    Basically, load the grid with an empty dataset (however, you prefer
    to create it) when you initially load the page (Not Page.IsPostBack).
    If you go with this approach it does not matter when the events fire
    (or why they fire).

    Just a different perspective.

    Regards,
    Dennis
  17. kavitha
    kavitha avatar
    16 posts
    Member since:
    Mar 2008

    Posted 16 Jun 2011 Link to this post

    Thanks Ashwin.

    e.RebindReason <> GridRebindReason.InitialLoad  helped me
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017