This is a migrated thread and some comments may be shown as answers.

Prevent grid load on page load

2 Answers 285 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Angie
Top achievements
Rank 1
Angie asked on 01 Jul 2008, 11:26 PM
How do I keep the RadGrid from loading (ie firing "need data source") when I access the page.  I want the grid to load only when the user clicks a specific button.  Thanks.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Jul 2008, 09:18 AM
Hi Angie,

Set the Visiblity of the RadGrid to false in the aspx and try populating the Grid in the click event of a Button as shown below.

ASPX:
<telerik:radgrid id="RadGrid1" runat="server"  Visible="false" onneeddatasource="RadGrid1_NeedDataSource"></telerik:radgrid> 

CS:
 protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
    { 
        BindGrid(); 
    } 
    protected void Button1_Click(object sender, EventArgs e) 
    { 
        BindGrid(); 
        RadGrid1.Rebind(); 
    } 
 
  private void BindGrid() 
    { 
        conn.Open(); 
        SqlDataAdapter adp = new SqlDataAdapter("select * from Projects", conn); 
        DataTable dt = new DataTable(); 
        adp.Fill(dt); 
        RadGrid1.DataSource = dt
        conn.Close(); 
        RadGrid1.Visible = true
    } 
         


Thanks
Shinu
0
Angie
Top achievements
Rank 1
answered on 07 Jul 2008, 05:05 PM
Thank you Shinu!
Tags
Grid
Asked by
Angie
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Angie
Top achievements
Rank 1
Share this question
or