<
asp:DropDownList
ID
=
"itemDropDownList"
runat
=
"server"
AutoPostBack
=
"True"
>
<
asp:ListItem
text
=
"(Select - One)"
/>
</
asp:DropDownList
>
<
telerik:RadToolTip
runat
=
"server"
ID
=
"booboo"
HideEvent
=
"ManualClose"
Position
=
"BottomRight"
Width
=
"350px"
Height
=
"70px"
Animation
=
"Fade"
ShowEvent
=
"OnClick"
ShowDelay
=
"0"
RelativeTo
=
"Element"
TargetControlID
=
"itemDropDownList"
Skin
=
"Windows7"
>
I'm your RADTOOLTIP
</
telerik:RadToolTip
>
I have followed the examples found elsewhere in the forums for adding a radcombobox to a listbox. Now that I have that working, how do I add the items to the control?
In the item template I have the following:
<
ItemTemplate
>
<
span
> <%# DataBinder.Eval(Container, "Text")%>
<
telerik:RadComboBox
ID
=
"radTimeClockIDs"
runat
=
"server"
CausesValidation
=
"False"
>
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"1"
Value
=
"1"
/>
<
telerik:RadComboBoxItem
Text
=
"2"
Value
=
"2"
/>
</
Items
>
</
telerik:RadComboBox
>
</
span
>
</
ItemTemplate
>
In the codebehind, I am adding items to the radlistbox, but they do not appear. I suspect that is because of the item template.
Now that I have the template in place, how do I add list items programmatically? Also, preliminarily I simply placed some items in the RadComboBox that is displayed. However, I will need to be able to put different items in the combobox based on the item that is placed as the list item.
My specific scenario requires a list of items that can be checked so the information can be supplied to a database function, however, each of the items that will populate the list will have a secondary value that is part of a configuration setting. The possible configuration values should appear in the RadComboBox, but each combobox may hold different values.
Essentially it will be three columns in the listbox. One with a checkbox, one with a text value and one with a combobox that is filled based on the text value in the listitem.
Is that possible with this control? If not, is there a better solution?
Thanks!
public partial class Default : System.Web.UI.Page
{
public class Customer
{
public int id { get; set; }
public string name { get; set; }
public string city { get; set; }
public List<
Contact
> Contacts { get; set; }
}
public class Contact
{
public int id { get; set; }
public string name { get; set; }
public string email { get; set; }
}
public static List<
Customer
> Customers = new List<
Customer
> {
new Customer() { id = 1, name = "Bridget", city = "New York", Contacts = new List<
Contact
>() {
new Contact() { id = 1, name = "John", email = "johnny@hotmail.com" },
new Contact() { id = 2, name = "Mark", email = "mark@hotmail.com" }
}
},
new Customer() { id = 2, name = "Carol", city = "London", Contacts = new List<
Contact
>() {
new Contact() { id = 1, name = "Henry", email = "henry@hotmail.com" },
new Contact() { id = 2, name = "Hugo", email = "hugo@hotmail.com" },
}
}
};
void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
{
GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
e.DetailTableView.DataSource = ((Customer)dataItem.DataItem).Contacts;
}
void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
if (!e.IsFromDetailTable)
RadGrid1.DataSource = Customers;
}
protected void Page_Init(object sender, EventArgs e)
{
RadGrid1.NeedDataSource += RadGrid1_NeedDataSource;
RadGrid1.DetailTableDataBind += RadGrid1_DetailTableDataBind;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;
RadGrid1.MasterTableView.AutoGenerateColumns = true;
RadGrid1.MasterTableView.DataKeyNames = new string[] { "id" };
GridTableView contactsTable = new GridTableView(RadGrid1);
contactsTable.AutoGenerateColumns = true;
RadGrid1.MasterTableView.DetailTables.Add(contactsTable);
}
}
}