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

Radlistview not binding correctly during rebind

1 Answer 244 Views
ListView
This is a migrated thread and some comments may be shown as answers.
deva sudan
Top achievements
Rank 2
deva sudan asked on 20 Oct 2010, 05:39 PM
Hello ,

I'm facing problem with rebinding RADListView from code behind by  changing the databasourceid in the event of RADTreeNode selection.

I'm desiging a page with Radtreeview and Radlistview and while clicking the node on the RADTreeView I'm getting the directory path from the treenode and assigning the selected directory to the RADListview in the code behind to list all images.  

Intermittently the RADListView is not getting the correct path and binding to a previously assigned values.  This is happening more frequently.

I'm displaying the same treenode selected path on a Gridview and that is showing the correct values for that selected treenode consistently.  It seems to be an issue with the RADListview binding using AJAX. 

Is there an alternate approach I can try to fix this dynamic biding issue?   Thanks for your help.

 

 

protected void RadTreeView1_Selected(object sender, RadTreeNodeEventArgs e)

 

{

 

 

if (e.Node.ToolTip == "Album")

 

{

 

 

string albpath = "";

 

 

 

if (RadTreeView1.SelectedNode.GetFullPath("/") == "Sample Folder/Sample Album")

 

{

 

 

albpath = "~/" + "Registered_Users_Uploaded_Images" + "/" + RadTreeView1.SelectedNode.GetFullPath("/");

 

}

 

 

else {

 

albpath =

 

"~/" + "Registered_Users_Uploaded_Images" + "/" + uname + "/" + RadTreeView1.SelectedNode.GetFullPath("/");

 

}

 

ObjectDataSource1.SelectParameters[

 

"path"].DefaultValue = albpath;

 

 

 

// ObjectDataSource1.SelectMethod = "GetData()";

 

RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadTreeView1, ObjectDataSource1);

 

RadListView1.DataSourceID =

 

"ObjectDataSource1";

 

RadListView1.Rebind();

 

RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadTreeView1, RadListView1);

}


}

============== ObjectDataSource=============

 

 

<asp:ObjectDataSource runat="server" ID="ObjectDataSource1" SelectMethod="GetData"

 

 

 

TypeName="uploadWebApp.DataProvider">

 

 

 

<SelectParameters>

 

 

 

<asp:Parameter Name="path" DefaultValue="~/Registered_Users_Uploaded_Images\dsnap1\My Albums\2010-10-16"/>

 

 

 

</SelectParameters>

 

 

 

</asp:ObjectDataSource>

 

=============================================

============ AJAX settings ==================

 

 

<telerik:AjaxSetting AjaxControlID="RadTreeView1">

 

 

 

<UpdatedControls>

 

 

 

<telerik:AjaxUpdatedControl ControlID="GridView1" />

 

 

 

<telerik:AjaxUpdatedControl ControlID="ObjectDataSource1" />

 

 

 

<telerik:AjaxUpdatedControl ControlID="RadListView1" LoadingPanelID="ListViewPanel1" />

 

<UpdatedControls>

 

 

</telerik:AjaxSetting>

 





1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 26 Oct 2010, 09:20 AM
Hello Deva,

Does the ListView bind correctly if you turn AJAX off (set EnableAJAX="False" for the RadAjaxManager)? If not so, it would be a good idea to see if the datasource is assigned at all to the ListView before Rebind() is called. Keep in mind that it is safer to pass the ID of the datasource using its ID property rather than using the string ID that you specified.

Also, see if calling DataBind() on the ObjectDataSource before assigning it to the ListView makes a change.

As for the AJAX functionality, are you adding the AJAX settings declaratively or programmatically? It seems you do both, which is possible but you are adding one and the same settings twice. Additionally, if you want to create AJAX setting programmatically, you should always do this in a Page event handler, which is executed each time during the page lifecycle (Page_Load, Page_PreRender) so that the control could be ajaxified when the page is initially loaded.

All the best,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ListView
Asked by
deva sudan
Top achievements
Rank 2
Answers by
Tsvetina
Telerik team
Share this question
or