6 Answers, 1 is accepted
0

Richard
Top achievements
Rank 1
answered on 15 Feb 2012, 04:50 PM
Duncan:
This topic is covered in-depth in the following forum thread:
How to disable dropdown when not databound?
Cheers!
This topic is covered in-depth in the following forum thread:
How to disable dropdown when not databound?
Cheers!
0

Duncan
Top achievements
Rank 2
answered on 15 Feb 2012, 05:06 PM
I'm sorry but that solution does not seem to work for me...
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function OnClientDropDownOpening(sender, eventArgs) {
var combo = $find("<%= cboTags.ClientID %>");
items = combo.get_items();
if (items.get_count() == 0) {
eventArgs.set_cancel(true);
}
}
</
script
>
</
telerik:RadScriptBlock
>
<
telerik:RadComboBox
ID
=
"cboTags"
runat
=
"server"
CssClass
=
"combo"
AutoPostBack
=
"true"
Width
=
"394px"
EnableEmbeddedBaseStylesheet
=
"False"
EnableEmbeddedSkins
=
"False"
EnableTheming
=
"False"
ItemsPerRequest
=
"8"
MarkFirstMatch
=
"True"
ShowMoreResultsBox
=
"True"
ShowToggleImage
=
"False"
EmptyMessage
=
"Tag Name"
DropDownCssClass
=
"combo-input-drop"
Filter
=
"Contains"
DropDownWidth
=
"410"
EnableAutomaticLoadOnDemand
=
"False"
EnableLoadOnDemand
=
"True"
OffsetX
=
"-38"
OffsetY
=
"-3"
ShowDropDownOnTextboxClick
=
"False"
DataTextField
=
"Tag"
DataValueField
=
"TagId"
EnableTextSelection
=
"False"
NoWrap
=
"True"
AllowCustomText
=
"True"
Height
=
"208"
OnItemsRequested
=
"cboTags_ItemsRequested"
ValidationGroup
=
"Form"
OnClientItemsRequested
=
"OnClientDropDownOpening"
>
</
telerik:RadComboBox
>
0

Richard
Top achievements
Rank 1
answered on 15 Feb 2012, 06:22 PM
Duncan:
Can you post your .aspx markup and code behind so that we can better understand your scenario?
Regards,
Can you post your .aspx markup and code behind so that we can better understand your scenario?
Regards,
0

Duncan
Top achievements
Rank 2
answered on 15 Feb 2012, 06:29 PM
<%@ Page Title="" Language="C#" MasterPageFile="~/App_Master/Application.master"
AutoEventWireup="true" CodeFile="Manage.aspx.cs" Inherits="Admin_Tags_Manage" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"ph_head"
runat
=
"Server"
>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"ph_content"
runat
=
"Server"
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function OnClientDropDownOpening(sender, eventArgs) {
var combo = $find("<%= cboTags.ClientID %>");
items = combo.get_items();
if (items.get_count() == 0) {
eventArgs.set_cancel(true);
}
}
</
script
>
</
telerik:RadScriptBlock
>
<
telerik:RadAjaxLoadingPanel
ID
=
"loadingpanelFull"
runat
=
"server"
Skin
=
""
Transparency
=
"30"
CssClass
=
"loading"
>
<
div
class
=
"full"
>
</
div
>
</
telerik:RadAjaxLoadingPanel
>
<
telerik:RadAjaxPanel
ID
=
"radAjaxPanel"
runat
=
"server"
LoadingPanelID
=
"loadingpanelFull"
>
<
asp:Panel
ID
=
"pnlOverlay"
runat
=
"server"
Visible
=
"false"
>
<
div
class
=
"sample_data_overlay"
>
</
div
>
<
div
class
=
"sample_data_popup"
>
<
h4
>
<
asp:Label
ID
=
"lblPopupHeader"
runat
=
"server"
/>
</
h4
>
<
p
>
<
asp:Label
ID
=
"lblPopupText"
runat
=
"server"
/></
p
>
<
asp:Panel
ID
=
"pnlActionButton"
runat
=
"server"
>
<
asp:HyperLink
ID
=
"lnkPopupAction"
runat
=
"server"
/>
</
asp:Panel
>
</
div
>
</
asp:Panel
>
<
asp:Repeater
ID
=
"rptChoicesMenu"
runat
=
"server"
OnItemCommand
=
"ChoicesMenu_ItemCommand"
OnItemDataBound
=
"ChoicesMenu_ItemDataBound"
>
<
HeaderTemplate
>
<
ul
class
=
"contentchoices"
>
</
HeaderTemplate
>
<
ItemTemplate
>
<
li
id
=
"ListItem"
runat
=
"server"
>
<
asp:LinkButton
ID
=
"btnItem"
runat
=
"server"
/></
li
>
</
ItemTemplate
>
<
FooterTemplate
>
</
ul
></
FooterTemplate
>
</
asp:Repeater
>
<
asp:Panel
ID
=
"pnlEditOverlay"
runat
=
"server"
Visible
=
"false"
>
<
div
class
=
"sample_data_overlay"
>
</
div
>
<
div
class
=
"sample_data_popup"
>
<
h4
>
Edit This Tag:</
h4
>
<
p
>
Please edit the tag and its related tags below.</
p
>
<
table
border
=
"0"
cellspacing
=
"0"
cellpadding
=
"0"
class
=
"editform"
>
<
tr
>
<
td
>
<
telerik:RadTextBox
ID
=
"txtTag"
runat
=
"server"
class
=
"textbox"
EnableEmbeddedBaseStylesheet
=
"False"
EnableEmbeddedSkins
=
"False"
EnableTheming
=
"False"
EmptyMessage
=
"Tag Name"
/>
</
td
>
</
tr
>
<
tr
>
<
th
>
Add/Remove Related Tags:
</
th
>
</
tr
>
<
tr
>
<
td
>
<
div
class
=
"withbutton"
>
<
asp:HiddenField
ID
=
"hdnCurrentTagId"
runat
=
"server"
/>
<
telerik:RadComboBox
ID
=
"cboTags"
runat
=
"server"
CssClass
=
"combo"
AutoPostBack
=
"true"
Width
=
"394px"
EnableEmbeddedBaseStylesheet
=
"False"
EnableEmbeddedSkins
=
"False"
EnableTheming
=
"False"
ItemsPerRequest
=
"8"
MarkFirstMatch
=
"True"
ShowMoreResultsBox
=
"True"
ShowToggleImage
=
"False"
EmptyMessage
=
"Tag Name"
DropDownCssClass
=
"combo-input-drop"
Filter
=
"Contains"
DropDownWidth
=
"410"
EnableAutomaticLoadOnDemand
=
"False"
EnableLoadOnDemand
=
"True"
OffsetX
=
"-38"
OffsetY
=
"-3"
ShowDropDownOnTextboxClick
=
"False"
DataTextField
=
"Tag"
DataValueField
=
"TagId"
EnableTextSelection
=
"False"
NoWrap
=
"True"
AllowCustomText
=
"True"
Height
=
"208"
OnItemsRequested
=
"cboTags_ItemsRequested"
ValidationGroup
=
"Form"
OnClientItemsRequested
=
"OnClientDropDownOpening"
>
</
telerik:RadComboBox
>
</
div
>
<
div
class
=
"add"
>
<
asp:LinkButton
ID
=
"btnAdd"
runat
=
"server"
OnClick
=
"btnAdd_Click"
ValidationGroup
=
"Form"
/>
</
div
>
</
td
>
</
tr
>
<
asp:Repeater
ID
=
"rptRelatedTags"
runat
=
"server"
OnItemCommand
=
"Tags_ItemCommand"
OnItemDataBound
=
"Tags_ItemDataBound"
>
<
ItemTemplate
>
<
tr
>
<
td
class
=
"urlcell"
>
<
div
class
=
"withbutton"
>
<
asp:LinkButton
ID
=
"btnTag"
runat
=
"server"
CommandName
=
"edit"
CausesValidation
=
"False"
/></
div
>
<
div
class
=
"remove"
>
<
asp:LinkButton
ID
=
"btnRemove"
runat
=
"server"
CommandName
=
"remove"
CausesValidation
=
"False"
/></
div
>
</
td
>
</
tr
>
</
ItemTemplate
>
</
asp:Repeater
>
<
tr
>
<
th
>
Other Tags Relating:
</
th
>
</
tr
>
<
asp:Repeater
ID
=
"rptRelatingTags"
runat
=
"server"
OnItemCommand
=
"Tags_ItemCommand"
OnItemDataBound
=
"Tags_ItemDataBound"
>
<
ItemTemplate
>
<
tr
>
<
td
class
=
"urlcell"
>
<
div
class
=
"withbutton"
>
<
asp:LinkButton
ID
=
"btnTag"
runat
=
"server"
CommandName
=
"edit"
CausesValidation
=
"False"
/></
div
>
<
div
class
=
"add"
>
<
asp:LinkButton
ID
=
"btnAdd"
runat
=
"server"
CommandName
=
"add"
CausesValidation
=
"False"
/></
div
>
</
td
>
</
tr
>
</
ItemTemplate
>
</
asp:Repeater
>
</
table
>
<
asp:Panel
ID
=
"pnlSaveButton"
runat
=
"server"
>
<
asp:LinkButton
ID
=
"btnSave"
runat
=
"server"
OnClick
=
"btnSave_Click"
/>
</
asp:Panel
>
<
div
class
=
"cancel"
>
<
asp:LinkButton
ID
=
"btnCancel"
runat
=
"server"
Text
=
"Cancel"
OnClick
=
"btnCancel_Click"
/></
div
>
</
div
>
</
asp:Panel
>
<
div
class
=
"clearfloat"
>
</
div
>
<
h1
>
New Tags Added</
h1
>
<
div
class
=
"stat-fullgraph"
>
<
div
class
=
"graph"
>
<
asp:Image
ID
=
"imgTagsAdded"
runat
=
"server"
/></
div
>
</
div
>
<
div
class
=
"clearfloat"
>
</
div
>
<
h1
>
Manage Tags</
h1
>
<
div
class
=
"clearfloat"
>
</
div
>
<
table
border
=
"0"
cellspacing
=
"0"
cellpadding
=
"0"
class
=
"datatable"
>
<
tr
>
<
td
>
<
div
class
=
"header"
>
<
div
class
=
"text"
>
The selected tags have related tags</
div
>
</
div
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"typerow"
>
Tags:
</
td
>
</
tr
>
<
asp:Repeater
ID
=
"rptItems"
runat
=
"server"
OnItemDataBound
=
"rptItems_ItemDataBound"
OnItemCommand
=
"rtpItems_ItemCommand"
>
<
ItemTemplate
>
<
tr
>
<
td
>
<
table
border
=
"0"
cellspacing
=
"0"
cellpadding
=
"0"
>
<
tr
class
=
"trhover"
>
<
td
class
=
"checkcol"
>
<
asp:CheckBox
ID
=
"chkHasRelated"
runat
=
"server"
AutoPostBack
=
"True"
Enabled
=
"false"
/>
</
td
>
<
td
class
=
"admin-itemcol"
>
<
div
>
<
asp:LinkButton
ID
=
"btnItemName"
CommandName
=
"edit"
runat
=
"server"
/> <
asp:Label
ID
=
"lblProfileFullName"
runat
=
"server"
/></
div
>
</
td
>
<
td
class
=
"admin-approvecol"
>
<
asp:LinkButton
ID
=
"btnApprove"
runat
=
"server"
CommandName
=
"approve"
Text
=
"Approve"
/>
</
td
>
<
td
class
=
"admin-removecol"
>
<
asp:LinkButton
ID
=
"btnRemove"
runat
=
"server"
CommandName
=
"remove"
Text
=
"Remove"
/>
</
td
>
</
tr
>
</
table
>
</
td
>
</
tr
>
</
ItemTemplate
>
</
asp:Repeater
>
</
table
>
</
telerik:RadAjaxPanel
>
</
asp:Content
>
The relevant parts of the code behind are:
protected
void
cboTags_ItemsRequested(
object
sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
{
Tags_DataBind();
}
public
void
Tags_DataBind()
{
TagsBL tagsbl =
new
TagsBL(conn);
cboTags.DataSource = tagsbl.GetAllTags(contextuser);
cboTags.DataBind();
cboTags.SortItems();
}
0

Richard
Top achievements
Rank 1
answered on 15 Feb 2012, 07:36 PM
Duncan:
Why not simply check to see if your RadComboBox.Item.Count == 0 after binding it, and if so, set RadComboBox.Enabled = false.
This simple mock up worked for me when the XML source file contains no items:
Hope this helps!
Why not simply check to see if your RadComboBox.Item.Count == 0 after binding it, and if so, set RadComboBox.Enabled = false.
This simple mock up worked for me when the XML source file contains no items:
using
Telerik.Web.UI;
public
partial
class
Default : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!Page.IsPostBack)
{
RadComboBox1.LoadContentFile(
"combobox2.xml"
);
if
(RadComboBox1.Items.Count == 0)
{
RadComboBox1.Enabled =
false
;
}
}
}
}
Hope this helps!
0

Duncan
Top achievements
Rank 2
answered on 17 Feb 2012, 12:53 AM
I'm not sure that would work with EnableLoadOnDemand set to true as there are always items being bound but not always being shown... if that makes sense...