protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
((e.Item
is
GridEditableItem || e.Item
is
GridDataItem) && e.Item.IsInEditMode)
{
GridEditableItem editForm = (GridEditableItem)e.Item;
(editForm.FindControl(
"ddlGridAdjBy"
)
as
DropDownList).SelectedValue = ((System.Data.DataRowView)(editForm.DataItem)).Row.ItemArray[1].ToString();
// throws an exception here
}
}
protected
void
RadGrid1_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && (e.Item
as
GridEditableItem).IsInEditMode) {
GridEditFormItem editItem = (GridEditFormItem)e.Item;
RadComboBox dropdownUOM = (RadComboBox)editItem.FindControl(
"editList"
);
// This PopulateDropDown works in populating the control with items
//
//For Each item As Something In CollectionThatGetsIterated
// Dim NewListItem As New RadComboBoxItem()
// NewListItem.Text = GetLocalizedText(item.Something1, item.Something2)
// NewListItem.Value = GetValue(item.Value)
// theDropDownControl.Items.Add(NewListItem)
//Next
PopulateDropDown(21, dropdownUOM);
dropdownUOM.DataBind();
}
}
// This is what sets the item and edit templates. Since the items in the dropdown are added to the Items collection in a loop vs. against a dataset/collection the ListTextField and ListValueFields are not set.
private
void
BuildLookupListColumn(
string
columnName, GridTemplateColumn existingTemplateColumn)
{
existingTemplateColumn.ItemTemplate =
new
CustomItemTemplate(columnName);
KeyValuePair<
string
,
string
> emptyListItem =
new
KeyValuePair<
string
,
string
>(
"Select"
,
string
.Empty);
existingTemplateColumn.EditItemTemplate =
new
CustomEditTemplate(columnName, emptyListItem);
existingTemplateColumn.ConvertEmptyStringToNull =
true
;
}
public
class
CustomEditTemplate: ITemplate, IBindableTemplate
{
private
string
_columnName;
private
KeyValuePair<
string
,
string
> _emptyListItem;
public
CustomEditTemplate()
{
}
public
CustomEditTemplate(
string
columnName, KeyValuePair<
string
,
string
> emptyListItem)
{
this
.ColumnName = columnName;
}
public
string
ColumnName {
get
{
return
_columnName; }
set
{ _columnName = value; }
}
public
KeyValuePair<
string
,
string
> EmptyListItem {
get
{
return
_emptyListItem; }
set
{ _emptyListItem = value; }
}
public
void
InstantiateIn(Control container)
{
RadComboBox displayControl =
new
RadComboBox();
displayControl.ID =
"editList"
;
displayControl.DataBinding += DisplayControl_DataBinding;
container.Controls.Add(displayControl);
}
private
void
DisplayControl_DataBinding(
object
sender, EventArgs e)
{
//Dim target As RadComboBox = DirectCast(sender, RadComboBox)
//Dim container As GridEditFormItem = DirectCast(target.NamingContainer, GridEditFormItem)
//Dim displayControl As RadComboBox = DirectCast(sender, RadComboBox)
//'Note: This line below throws a binding error on insert DataBinding: 'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'AccountSettings'.
//displayControl.SelectedValue = DataBinder.Eval(container.DataItem, ColumnName).ToString()
//displayControl.SelectedValue = displayControl.SelectedValue
}
public
System.Collections.Specialized.IOrderedDictionary ExtractValues(Control container)
{
OrderedDictionary dict =
new
OrderedDictionary();
string
value;
value = (((RadComboBox)((GridEditFormItem)container).FindControl(
"editList"
)).SelectedValue);
dict.Add(ColumnName, value);
return
dict;
}
}
public
class
CustomItemTemplate : ITemplate
{
private
string
_columnName;
public
CustomItemTemplate()
{
}
public
CustomItemTemplate(
string
columnName)
{
this
.ColumnName = columnName;
}
public
string
ColumnName {
get
{
return
_columnName; }
set
{ _columnName = value; }
}
public
void
InstantiateIn(Control container)
{
LiteralControl displayControl =
new
LiteralControl();
displayControl.ID =
"litEditList"
;
displayControl.DataBinding += DisplayControl_DataBinding;
container.Controls.Add(displayControl);
}
private
void
DisplayControl_DataBinding(
object
sender, EventArgs e)
{
LiteralControl target = (LiteralControl)sender;
GridDataItem container = (GridDataItem)target.NamingContainer;
target.Text = (DataRowView)container.DataItem(_columnName).ToString();
}
}
I'm working on a project for a client, where the app I'm building will serve to edit an XML file consumed by a live application. The application is written in Flash, and quite unstable, so I am kind of stuck with the less than optimal XML setup.
The XML is made up (simplified) like the following:
<
MenuItem
id
=
"1"
label
=
"category1"
>
<
Description
>Description for Category 1</
Description
>
<
Image
>Image for category 1</
Image
>
<
Item
label
=
"Category1Item1"
>
<
Price
>12.99</
Price
>
<
Type
>Wood</
Type
>
<
additionalElementsHere
/>
</
Item
>
<
Item
label
=
"Category1Item2"
>
<
Price
>112.99</
Price
>
<
Type
>Stone</
Type
>
<
additionalElementsHere
/>
</
Item
>
<
AdditionalItemsHere
/>
</
MenuItem
>
<
AdditionMenuITemsHere
/>
I've been using a Telerik treeview bound to an XMLDataSource to display the data and allow users to interact with it (add/delete nodes, move nodes by means of drag and drop, or copy nodes and the underlying elements). So far, so good.
Now my client would like to know if it is somehow possible to use the <Type> Element of the Item elements as grouping containers.
So currently the treeview looks like this:
category1
--Category1Item1
--Category1Item2
And ideally, it should end up looking like this:
category1
--Wood
----Category1Item1
----Category1Item123
--Stone
----Category1Item2
----Category1Item456
I read up on HierarchicalDataTemnplates, but have not managed to figure out if these work in the ASP.NET controls supplied by Telerik. I would like to try and stick to what I have so far, as many hours of work have already gone into the product so far.
I'd appreciate it if someone could point me in the right direction of how to tackle this particular issue.
Thanks in advance :)
Peter
RadScheduler1.SelectedView = SchedulerViewType.TimelineView;
RadScheduler1.TimelineView.SlotDuration = TimeSpan.Parse("14.00:00:00");
RadScheduler1.TimelineView.ColumnHeaderDateFormat = "MM/dd/yyyy";
RadScheduler1.ColumnWidth = 180;
RadScheduler1.TimelineView.TimeLabelSpan = 1;
RadScheduler1.TimelineView.NumberOfSlots = 6;
</telerik:RadOrgChart>
protected void Page_Load(object sender, EventArgs e)
{
BindToDataSet(this.RadOrgChart1);
}
private static void BindToDataSet(RadOrgChart orgChart)
{
string dbConnectionString = ConfigurationManager.ConnectionStrings["mambophilprod"].ConnectionString;
MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT Id, ParentId, CurrentPosition From mambophil_flat_tree",
dbConnectionString);
DataSet links = new DataSet();
adapter.Fill(links);
orgChart.DataTextField = "CurrentPosition";
orgChart.DataFieldID = "Id";
orgChart.DataFieldParentID = "ParentID";
orgChart.DataSource = links;
orgChart.DataBind();
}
This is what I would like to do.
- I want to show the first few levels (say 10)
- When the user clicks on one of the last levels, the system fetches the next 10 levels.
Is this possible? Appreciate your help.
Sree
Idid a same thing with another page in the same namespace and its working
but here its not working and I am forced to paste the code ,Please sugggest the solution
<%@ Page Title="Subscribe for Category" Async="true" Language="C#" MasterPageFile="~/singleMaster.master" AutoEventWireup="true" CodeFile="SuscribeCat.aspx.cs" Inherits="SuscribeCat" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"head"
Runat
=
"Server"
>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"ContentPlaceHolder1"
Runat
=
"Server"
>
<
telerik:RadStyleSheetManager
ID
=
"RadStyleSheetManager1"
runat
=
"server"
>
</
telerik:RadStyleSheetManager
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
Runat
=
"server"
>
</
telerik:RadScriptManager
>
<
br
/>
<
h2
> My Expert Profile</
h2
>
<
br
/>
<
table
style
=
"width:800px"
>
<
tr
>
<
td
style
=
"width:3%"
>
</
td
>
<
td
>The main Categories you Subscribed</
td
>
</
tr
>
</
table
>
<
br
/>
<
table
style
=
" width:800px"
>
<
tr
>
<
td
style
=
" width:5%"
></
td
><
td
>
<
telerik:RadGrid
ID
=
"sub_cat_gird"
OnItemCommand
=
"del_sub"
ShowHeader
=
"false"
ShowFooter
=
"false"
runat
=
"server"
Width
=
"600px"
Skin
=
"Sitefinity"
AutoGenerateColumns
=
"false"
>
<
MasterTableView
>
<
NoRecordsTemplate
> </
NoRecordsTemplate
>
<
Columns
>
<
telerik:GridTemplateColumn
>
<
ItemStyle
Width
=
"70px"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblbl"
runat
=
"server"
Text= '<%#Eval("name")%>' ></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
><
ItemStyle
Width
=
"50px"
/> <
ItemTemplate
> >> </
ItemTemplate
> </
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
ItemStyle
Width
=
"70px"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lml"
runat
=
"server"
Text='<%#Eval("sub_name") %>' ></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
><
ItemStyle
Width
=
"50px"
/> <
ItemTemplate
></
ItemTemplate
> </
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
><
ItemStyle
Width
=
"70px"
/> <
ItemTemplate
></
ItemTemplate
> </
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
ItemStyle
/>
<
ItemTemplate
>
<
asp:Button
ID
=
"btn1"
runat
=
"server"
Text
=
"Delete"
CssClass
=
"art-button"
CommandName
=
"del_sub"
CommandArgument=<%#Eval("sub_cat_id") %> />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
td
>
</
tr
>
</
table
>
<%--<
table
style
=
"width:800px"
>
<
tr
><
td
style
=
" width:5%"
></
td
></
tr
>
</
table
>--%>
<
table
style
=
" width:800px"
>
<
tr
>
<
td
style
=
" width:5%"
></
td
>
<
td
>
<
telerik:RadGrid
ID
=
"sub_sub_cat_grid"
ShowHeader
=
"false"
ShowFooter
=
"false"
runat
=
"server"
Width
=
"600px"
Skin
=
"Sitefinity"
OnItemCommand
=
"del_sub_sub"
AutoGenerateColumns
=
"false"
>
<
MasterTableView
>
<
NoRecordsTemplate
> </
NoRecordsTemplate
>
<
Columns
>
<
telerik:GridTemplateColumn
>
<
ItemStyle
Width
=
"70px"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lki"
runat
=
"server"
Text = '<%#Eval("main_name")%>' ></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
><
ItemStyle
Width
=
"50px"
/> <
ItemTemplate
> >> </
ItemTemplate
> </
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
ItemStyle
Width
=
"70px"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lml"
runat
=
"server"
Text='<%#Eval("sub_name") %>' ></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
><
ItemStyle
Width
=
"50px"
/> <
ItemTemplate
> >> </
ItemTemplate
> </
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
ItemStyle
Width
=
"70px"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lml1"
runat
=
"server"
Text='<%#Eval("sub_sub_name") %>' ></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
ItemStyle
/>
<
ItemTemplate
>
<
asp:Button
ID
=
"btn1"
runat
=
"server"
Text
=
"Delete"
CssClass
=
"art-button"
CommandName
=
"del_sub_sub"
CommandArgument=<%#Eval("sub_sub_cat_id") %> />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
></
td
>
</
tr
>
</
table
>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
telerik:RadAjaxPanel
ID
=
"panel"
runat
=
"server"
>
<
table
style
=
" width:800px"
>
<
tr
style
=
" height:40px"
>
<
td
style
=
" width:5%"
></
td
>
<
td
style
=
" width:25%"
> Select Main Category</
td
>
<
td
>
<
asp:DropDownList
ID
=
"DropDownList1"
AppendDataBoundItems
=
"true"
runat
=
"server"
DataSourceID
=
"main_cat"
DataTextField
=
"name"
DataValueField
=
"main_cat_id"
onselectedindexchanged
=
"DropDownList1_SelectedIndexChanged"
Width
=
"200px"
AutoPostBack
=
"true"
>
<
asp:ListItem
Selected
=
"True"
Value
=
"0"
>Select a Category</
asp:ListItem
>
</
asp:DropDownList
>
<
asp:SqlDataSource
ID
=
"main_cat"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:QConnection %>"
SelectCommand="SELECT [main_cat_id], [name] FROM [main_cat_tbl]"></
asp:SqlDataSource
>
</
td
>
</
tr
>
<
tr
style
=
" height:40px"
>
<
td
style
=
" width:5%"
></
td
>
<
td
style
=
" width:25%"
> Select Sub-Category</
td
>
<
td
>
<
asp:DropDownList
ID
=
"DropDownList2"
runat
=
"server"
DataSourceID
=
"sub_cat"
DataTextField
=
"name"
DataValueField
=
"sub_cat_id"
onselectedindexchanged
=
"DropDownList2_SelectedIndexChanged"
Width
=
"200px"
Enabled
=
"false"
AutoPostBack
=
"true"
AppendDataBoundItems
=
"True"
>
<
asp:ListItem
Selected
=
"True"
Value
=
"0"
>Select a subcategory</
asp:ListItem
>
</
asp:DropDownList
>
<
asp:SqlDataSource
ID
=
"sub_cat"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:QConnection %>"
SelectCommand="select sub_cat_id, name from sub_cat_tbl where main_cat_id=@main_cat_id ">
<
SelectParameters
>
<
asp:ControlParameter
ControlID
=
"DropDownList1"
Name
=
"main_cat_id"
PropertyName
=
"SelectedValue"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
</
td
>
</
tr
>
<
tr
style
=
" height:40px"
>
<
td
style
=
" width:5%"
></
td
>
<
td
style
=
" width:25%"
> Select Sub-Sub Category</
td
>
<
td
>
<
asp:DropDownList
ID
=
"DropDownList3"
runat
=
"server"
DataSourceID
=
"sub_sub_cat"
DataTextField
=
"name"
DataValueField
=
"sub_sub_cat_id"
Enabled
=
"false"
Width
=
"200px"
AutoPostBack
=
"true"
AppendDataBoundItems
=
"True"
>
<
asp:ListItem
Selected
=
"True"
Value
=
"0"
>Select a subcategory</
asp:ListItem
>
</
asp:DropDownList
>
<
asp:SqlDataSource
ID
=
"sub_sub_cat"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:QConnection %>"
SelectCommand="select sub_sub_cat_id, name from sub_sub_cat_tbl where sub_cat_id=@sub_cat_id ">
<
SelectParameters
>
<
asp:ControlParameter
ControlID
=
"DropDownList2"
Name
=
"sub_cat_id"
PropertyName
=
"SelectedValue"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
</
td
>
</
tr
>
<
tr
style
=
" height:60px"
>
<
td
style
=
" width:5%"
></
td
>
<
td
style
=
" width:25%"
></
td
>
<
td
>
<
asp:Button
ID
=
"Button1"
runat
=
"server"
Text
=
"Sign up as expert"
onclick
=
"Button1_Click"
/>
</
td
>
</
tr
>
<
tr
>
<
td
></
td
><
td
></
td
><
td
></
td
><
td
> <
asp:Label
ID
=
"SuscribtionStatus"
runat
=
"server"
Visible
=
"false"
></
asp:Label
></
td
>
</
tr
>
</
table
>
</
telerik:RadAjaxPanel
>
<
telerik:RadAjaxManager
ID
=
"ajax_manger"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"DropDownList1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"DropDownList1"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"DropDownList2"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"DropDownList2"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"DropDownList2"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"DropDownList3"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"DropDownList3"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"DropDownList3"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"Button1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"sub_cat_gird"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"sub_sub_cat_grid"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
</
asp:Content
>