When binding data to the RadComboBox utilizing an Ajax panel, the RadComboBox loses its datasource when used within a master page. The RadComboBox is populated on initial load, but after making a selection, it loses the datasource.
My master page markup:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="Management.Web.Site1" %> |
<!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></title> |
<asp:ContentPlaceHolder ID="head" runat="server"> |
</asp:ContentPlaceHolder> |
</head> |
<body> |
<form id="form1" runat="server"> |
<div> |
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> |
</asp:ContentPlaceHolder> |
</div> |
</form> |
</body> |
</html> |
My content page markup (WebForm1):
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" |
CodeBehind="WebForm1.aspx.cs" Inherits="Management.Web.WebForm1" %> |
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> |
</asp:Content> |
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server" |
ViewStateMode="Enabled"> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
</telerik:RadScriptManager> |
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"> |
<telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"> |
</telerik:RadComboBox> |
</telerik:RadAjaxPanel> |
</asp:Content> |
My non-master page markup (WebForm2):
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="Management.Web.WebForm2" %> |
<!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></title> |
</head> |
<body> |
<form id="form1" runat="server"> |
<div> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
</telerik:RadScriptManager> |
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"> |
<telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"> |
</telerik:RadComboBox> |
</telerik:RadAjaxPanel> |
</div> |
</form> |
</body> |
</html> |
My code behind (of both the content and non-master pages):
using System; |
using System.Web.UI; |
namespace Management.Web |
{ |
public partial class WebForm1 : System.Web.UI.Page |
{ |
protected void Page_Load(object sender, EventArgs e) |
{ |
if (!Page.IsPostBack) |
this.LoadTags(); |
} |
private void LoadTags() |
{ |
TagManager mgr = new TagManager(); |
RadComboBox1.DataSource = mgr.GetAllByModuleId(5); |
RadComboBox1.DataValueField = "Id"; |
RadComboBox1.DataTextField = "Name"; |
RadComboBox1.DataBind(); |
} |
protected void RadComboBox1_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e) |
{ |
} |
} |
} |
As you can see, the code is VERY basic. The TagManager is a class that returns the data.
When using the Master Page (WebForm1), you lose the datasource after you make your first selection. If you attempt to click on the drop down arrow, after making your initial selection, the RadComboBox is empty (doesn't even respond to the click).
When using the non Master Page (WebForm2), the datasource is persisted no matter how many times you make a selection in the RadComboBox.
Any thoughts why there is a difference when using a master page?