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

[Solved] Binding in the NeedDataSource event

1 Answer 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 27 May 2009, 03:24 PM
Update: I think its a side effect of a different control I am using

I have a control on the page that does an ajax request back to a page e.g.(clicking a button) in that button event I am making a call to some web service. After I get the results back from that call I am using linq to filter down the data by some items on the page.
I tired setting the data source of my grid after I am done with the linq filtering but rows never show up on the page. I ended up reading this link Rebind grid on command/postback event with EnableViewState = false thiking that would be what I need to do, but that has not worked for me either.

Here is some of the code I have written.

public class Programs 
    { 
        public string Name 
        { 
            get
            set
        } 
        public bool Required 
        { 
            get
            set
        } 
 
        public bool Approved 
        { 
            get
            set
        } 
    } 
 
 public partial class Charts: Page 
    { 
        List<Programs> ProgramList; 
 
 
 protected void Button_Click(object sender, ImageClickEventArgs e) 
 
   
                //Programs has items in it and is declare as a var 
                // for brevity sake I left out the filtering  code 
                ProgramList = programs; 
 
                DetailsGrid.DataSource = null
                DetailsGrid.Rebind(); 
 
protected void DetailsGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
        { 
            if (ProgramList != null
            { 
                DetailsGrid.DataSource = ProgramList; 
 
            } 

That datasource is set and the Items created code does run but the grid never shows up on the page. It

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 30 May 2009, 08:26 AM
Hello Mark,

Could you verify that the grid is also ajaxified? In other words if the button is set as an Ajax initiator, is the grid set as updated control? Here is a code snippet showing how to add Ajax settings in order to update the grid after the changes are made:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="Button1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 

For further information please examine this online help article.

Regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or