Peter Maslin
Top achievements
Rank 1
Peter Maslin
asked on 30 Jun 2010, 09:27 AM
hi
i am programmatically creating the list view and on the item template i am adding the edit and delete command buttons as per the demo like so :-
the list view is defined as follows :-
but if i click on the edit button nothing seems to happen , am i missing an event or trigger ?
Peter
i am programmatically creating the list view and on the item template i am adding the edit and delete command buttons as per the demo like so :-
TableRow ControlRow = new TableRow(); |
TableCell Cell1 = new TableCell(); |
ImageButton imageButton = new ImageButton(); |
imageButton.ID = "UpdateButton"; |
imageButton.CommandName = "Update"; |
imageButton.ImageUrl = "Img/site/buttons/Update.gif"; |
Cell1.Controls.Add(imageButton); |
ImageButton DeleteButton = new ImageButton(); |
DeleteButton.ID = "CancelButton"; |
DeleteButton.CommandName = "Cancel"; |
DeleteButton.ImageUrl = "Img/site/buttons/Cancel.gif"; |
Cell1.Controls.Add(DeleteButton); |
ControlRow.Cells.Add(Cell1); |
DisplayTable.Rows.Add(ControlRow); |
NewPanel.Controls.Add(DisplayTable); |
container.Controls.Add(NewPanel); |
the list view is defined as follows :-
private RadListView CreateList(XmlNode Template) |
{ |
RadListView MyList = new RadListView(); |
MyList.ID = Template.Attributes["Name"].Value; |
MyList.Width = Unit.Pixel(600); |
MyList.DataSource = GetBaseData(Template); |
MyList.DataMember = Template.Attributes["Name"].Value; |
MyList.LayoutTemplate = new LayoutTemplate(Template); |
MyList.ItemTemplate = new ItemTemplate(Template); |
MyList.AlternatingItemTemplate = new ItemTemplate(Template); |
MyList.EmptyDataTemplate = new EmptyDataTemplate(Template); |
MyList.EditItemTemplate = new EditItemTemplate(Template); |
MyList.InsertItemTemplate = new EditItemTemplate(Template); |
MyList.SelectedItemTemplate = new ItemTemplate(Template); |
MyList.ItemPlaceholderID = "itemPlaceholder"; |
MyList.ItemInserted += new EventHandler<RadListViewInsertedEventArgs>(MyList_ItemInserted); |
MyList.ItemUpdated += new EventHandler<RadListViewUpdatedEventArgs>(MyList_ItemUpdated); |
MyList.ItemDeleted += new EventHandler<RadListViewDeletedEventArgs>(MyList_ItemDeleted); |
MyList.NeedDataSource += new EventHandler<RadListViewNeedDataSourceEventArgs>(MyList_NeedDataSource); |
MyList.ItemCommand += new EventHandler<RadListViewCommandEventArgs>(MyList_ItemCommand); |
return MyList; |
} |
but if i click on the edit button nothing seems to happen , am i missing an event or trigger ?
Peter
7 Answers, 1 is accepted
0
Peter Maslin
Top achievements
Rank 1
answered on 30 Jun 2010, 11:16 AM
i have been doing some investigating , and think it is because of the programmatic creation of the component including the applying of the data set ,
when the edit button is clicked the post back is activated and the controls are rendered again but it doesnt seem to be preserving state like other controls like the radgrid etc , perhaps it is something i am missing that i need to do etc.
when the edit button is clicked the post back is activated and the controls are rendered again but it doesnt seem to be preserving state like other controls like the radgrid etc , perhaps it is something i am missing that i need to do etc.
0
Hello Peter,
Can you please provide the page's full source code? This will give us more details about at which point in page's lifecycle the RadListView is created.
All the best,
Rosen
the Telerik team
Can you please provide the page's full source code? This will give us more details about at which point in page's lifecycle the RadListView is created.
All the best,
Rosen
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
0
Peter Maslin
Top achievements
Rank 1
answered on 30 Jun 2010, 11:28 AM
ok ill post it here for you.
Staff.aspx page
Staff.aspx.cs
i appreciate any assistance you can provide.
Staff.aspx page
<%@ Page Language="C#" MasterPageFile="~/Portal.Master" AutoEventWireup="true" Codebehind="Staff.aspx.cs" |
Inherits="PortalFrontEnd.Staff" Title="Untitled Page" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<%@ Register Src="userControls/Logout.ascx" TagName="Logout" TagPrefix="uc1" %> |
<%@ MasterType VirtualPath="~/Portal.Master" %> |
<asp:Content ID="Content1" ContentPlaceHolderID="cph1" runat="server"> |
<div id="pageBody" class="standardTwoColumn"> |
<div id="pageBodyInner"> |
<div id="contentWrapper"> |
<div id="sideNav"> |
<strong>Staff</strong> |
<div id="sideNavInner" style="height: 800px;"> |
<telerik:RadTreeView ID="RadTreeView1" runat="server" SingleExpandPath="True" Skin="Web20" |
OnNodeClick="RadTreeView1_NodeClick" Width="200px" Height="100%"> |
</telerik:RadTreeView> |
<br /> |
<asp:Button ID="btnNew" Text="Add Staff" runat="server" OnClick="btnNew_Click" /> |
</div> |
</div> |
<div id="content"> |
<h1> |
Staff |
</h1> |
<div id="contentInner"> |
<telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" /> |
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" /> |
<telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1"> |
<asp:PlaceHolder ID="PlaceHolder1" runat="server"> |
<h2> |
Welcome to the Staff Section</h2> |
<p> |
Please Select the member of staff you wish to edit from the lists on the left. |
</p> |
<p> |
if you know what role the member of staff is in please go by the "Active Staff by |
role" group otherwise expand the "Active staff by name" |
</p> |
<p> |
the "old staff" groups are there to allow you to view/edit members of staff who |
have no active roles within your centre. |
</p> |
<p> |
if you wish to add a new member of staff please press the "Add Staff" button , but |
please check the existing lists before you do so to ensure you don't add the same |
member of staff twice. |
</p> |
</asp:PlaceHolder> |
</telerik:RadAjaxPanel> |
</div> |
</div> |
</div> |
</div> |
</div> |
</asp:Content> |
Staff.aspx.cs
using System; |
using System.Data; |
using System.Configuration; |
using System.Collections; |
using System.Collections.Specialized; |
using System.Web; |
using System.Web.Security; |
using System.Web.UI; |
using System.Web.UI.WebControls; |
using System.Web.UI.WebControls.WebParts; |
using System.Web.UI.HtmlControls; |
using System.Xml; |
using Telerik.Web.UI; |
using System.Text; |
using PortalFrontEnd.userControls; |
namespace PortalFrontEnd |
{ |
public partial class Staff : System.Web.UI.Page |
{ |
protected void Page_Load(object sender, EventArgs e) |
{ |
} |
protected void Page_Init(object sender, EventArgs e) |
{ |
string ID = Request.QueryString["ID"]; |
string NEW = Request.QueryString["New"]; |
Master.Page.Header.Title = "HFEA Portal - Staff"; |
if (WebUtils.CookieCutter.ReadCookie("HFEA_OL_SG").Length == 0) |
{ |
Response.Redirect("Login.aspx", false); |
} |
Centrepede.clsWebService MyWeb = new PortalFrontEnd.Centrepede.clsWebService(); |
if (!MyWeb.CanView("CP_StaffTab")) |
{ |
Response.Redirect("Dashboard.aspx?s=1", false); |
} |
CreateStaffTree(); |
if (ID != null) |
{ |
CreateStaffPanels(); |
} |
if (NEW != null) |
{ |
CreateNewStaffPanels(); |
} |
} |
/// <summary> |
/// Creates the staff tree. |
/// </summary> |
private void CreateStaffTree() |
{ |
string ID = Request.QueryString["ID"]; |
Centrepede.clsWebService MyWeb = new PortalFrontEnd.Centrepede.clsWebService(); |
XmlDocument xStaffTree = MyWeb.GetStaffTreeView(); |
DataSet MyDS = GetStandardBaseData(xStaffTree); |
RadTreeView1.DataSource = MyDS; |
RadTreeView1.DataMember = "Data"; |
RadTreeView1.DataFieldID = "ID"; |
RadTreeView1.DataFieldParentID = "ParentID"; |
RadTreeView1.DataValueField = "ID"; |
RadTreeView1.DataTextField = "Text"; |
RadTreeView1.DataBind(); |
if (ID != null) |
{ |
RadTreeView1.FindNodeByValue(ID).Selected = true; |
RadTreeView1.FindNodeByValue(ID).Expanded = true; |
RadTreeView1.FindNodeByValue(ID).ExpandParentNodes(); |
} |
} |
/// <summary> |
/// Gets the base data. |
/// </summary> |
/// <param name="Template">The template.</param> |
/// <returns></returns> |
private DataSet GetBaseData(XmlNode Template) |
{ |
XmlNodeList xDropNode = Template.SelectNodes("Data"); |
DataSet MyDS = new DataSet("CentreData"); |
DataTable MyDT = new DataTable(Template.Attributes["Name"].Value); |
foreach (XmlNode xControl in Template.SelectNodes("Controls")) |
{ |
MyDT.Columns.Add(xControl.Attributes["Name"].Value, typeof(string)); |
} |
if (xDropNode != null) |
{ |
foreach (XmlNode xItem in xDropNode) |
{ |
DataRow dr = MyDT.NewRow(); |
foreach (XmlAttribute xAtt in xItem.Attributes) |
{ |
if (MyDT.Columns.Contains(xAtt.Name)) |
{ |
dr[xAtt.Name] = xAtt.Value; |
} |
else |
{ |
MyDT.Columns.Add(xAtt.Name, typeof(string)); |
dr[xAtt.Name] = xAtt.Value; |
} |
} |
MyDT.Rows.Add(dr); |
} |
} |
MyDS.Tables.Add(MyDT); |
foreach (XmlNode xNode in Template.SelectNodes("Controls[@Type='Drop']")) |
{ |
DataTable DropTable = new DataTable(xNode.Attributes["Name"].Value); |
foreach (XmlAttribute xAtt in xNode.FirstChild.Attributes) |
{ |
DropTable.Columns.Add(xAtt.Name, typeof(string)); |
} |
foreach (XmlNode xItem in xNode) |
{ |
DataRow dr = DropTable.NewRow(); |
foreach (XmlAttribute xAtt in xItem.Attributes) |
{ |
dr[xAtt.Name] = xAtt.Value; |
} |
DropTable.Rows.Add(dr); |
} |
MyDS.Tables.Add(DropTable); |
} |
return MyDS; |
} |
/// <summary> |
/// Gets the base data. |
/// </summary> |
/// <param name="xDoc">The x doc.</param> |
/// <returns></returns> |
private DataSet GetBaseData(XmlDocument xDoc) |
{ |
DataSet MyDataSet = new DataSet("CentreData"); |
#region "Base Data Tables" |
foreach (XmlNode xNode in xDoc.SelectNodes("HFEA/Object/Group")) |
{ |
//Base Data Tables |
DataTable GroupTable = new DataTable(xNode.Attributes["Name"].Value); |
XmlNodeList xDropNode = xNode.SelectNodes("Data"); |
foreach (XmlNode xControl in xNode.SelectNodes("Controls")) |
{ |
GroupTable.Columns.Add(xControl.Attributes["Name"].Value, typeof(string)); |
} |
//Primary and Foreign Keys |
//GroupTable.Constraints.Add(xNode.Attributes["Name"].Value + "PKey", GroupTable.Columns["ID"], true); |
if (xDropNode != null) |
{ |
foreach (XmlNode xItem in xDropNode) |
{ |
DataRow dr = GroupTable.NewRow(); |
foreach (XmlAttribute xAtt in xItem.Attributes) |
{ |
if (GroupTable.Columns.Contains(xAtt.Name)) |
{ |
dr[xAtt.Name] = xAtt.Value; |
} |
else |
{ |
GroupTable.Columns.Add(xAtt.Name, typeof(string)); |
dr[xAtt.Name] = xAtt.Value; |
} |
} |
GroupTable.Rows.Add(dr); |
} |
} |
MyDataSet.Tables.Add(GroupTable); |
} |
#endregion |
#region "Drop Down Data" |
foreach (XmlNode GroupNode in xDoc.SelectNodes("HFEA/Object/Group")) |
{ |
foreach (XmlNode xNode in GroupNode.SelectNodes("Controls[@Type='Drop']")) |
{ |
DataTable DropTable = new DataTable(xNode.Attributes["Name"].Value); |
foreach (XmlAttribute xAtt in xNode.FirstChild.Attributes) |
{ |
DropTable.Columns.Add(xAtt.Name, typeof(string)); |
} |
foreach (XmlNode xItem in xNode) |
{ |
DataRow dr = DropTable.NewRow(); |
foreach (XmlAttribute xAtt in xItem.Attributes) |
{ |
dr[xAtt.Name] = xAtt.Value; |
} |
DropTable.Rows.Add(dr); |
} |
MyDataSet.Tables.Add(DropTable); |
} |
} |
#endregion |
foreach (XmlNode xNode in xDoc.SelectNodes("HFEA/Object/Group")) |
{ |
if (xNode.Attributes["GroupLink"] != null) |
{ |
DataColumn ParentCol = MyDataSet.Tables[xNode.Attributes["GroupLink"].Value].Columns[xNode.Attributes["GroupLinkID"].Value]; |
DataColumn ChildCol = MyDataSet.Tables[xNode.Attributes["Name"].Value].Columns[xNode.Attributes["GroupLinkID"].Value]; |
MyDataSet.Relations.Add(xNode.Attributes["Name"].Value + "FKey", ParentCol, ChildCol); |
} |
} |
return MyDataSet; |
} |
/// <summary> |
/// Gets the standard base data. |
/// </summary> |
/// <param name="xDoc">The x doc.</param> |
/// <returns></returns> |
private DataSet GetStandardBaseData(XmlDocument xDoc) |
{ |
DataSet MyDataSet = new DataSet("CentreData"); |
DataTable GroupTable = new DataTable("Data"); |
foreach (XmlNode xNode in xDoc.SelectNodes("HFEA/Data")) |
{ |
//Base Data Tables |
foreach (XmlAttribute xAtt in xNode.Attributes) |
{ |
if (!GroupTable.Columns.Contains(xAtt.Name)) |
{ |
GroupTable.Columns.Add(xAtt.Name, typeof(string)); |
} |
} |
DataRow dr = GroupTable.NewRow(); |
foreach (XmlAttribute xAtt in xNode.Attributes) |
{ |
if (GroupTable.Columns.Contains(xAtt.Name)) |
{ |
if (xAtt.Value == string.Empty) |
{ |
dr[xAtt.Name] = DBNull.Value; |
} |
else |
{ |
dr[xAtt.Name] = xAtt.Value; |
} |
} |
else |
{ |
GroupTable.Columns.Add(xAtt.Name, typeof(string)); |
dr[xAtt.Name] = xAtt.Value; |
} |
} |
GroupTable.Rows.Add(dr); |
} |
MyDataSet.Tables.Add(GroupTable); |
return MyDataSet; |
} |
/// <summary> |
/// Handles the NodeClick event of the RadTreeView1 control. |
/// </summary> |
/// <param name="sender">The source of the event.</param> |
/// <param name="e">The <see cref="Telerik.Web.UI.RadTreeNodeEventArgs"/> instance containing the event data.</param> |
protected void RadTreeView1_NodeClick(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e) |
{ |
string SelectXML = string.Empty; |
if (e.Node.Nodes.Count == 0) |
{ |
Response.Redirect("Staff.aspx?s=6&ID=" + e.Node.Value); |
} |
else |
{ |
e.Node.Expanded = true; |
e.Node.ExpandParentNodes(); |
} |
} |
/// <summary> |
/// Handles the Click event of the btnNew control. |
/// </summary> |
/// <param name="sender">The source of the event.</param> |
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> |
protected void btnNew_Click(object sender, EventArgs e) |
{ |
Response.Redirect("Staff.aspx?s=6&NEW=Yes"); |
} |
/// <summary> |
/// Gets the staff data. |
/// </summary> |
/// <returns></returns> |
private XmlDocument GetStaffData() |
{ |
Centrepede.clsWebService MyWeb = new PortalFrontEnd.Centrepede.clsWebService(); |
string SelectXML = string.Empty; |
//is Tree Based on Role id |
if (RadTreeView1.SelectedNode.FullPath.Contains("role")) |
{ |
SelectXML = "<HFEA><Criteria RoleID='" + RadTreeView1.SelectedNode.Value + "'></Criteria></HFEA>"; |
} |
//is Tree based on person id |
if (RadTreeView1.SelectedNode.ParentNode.Text.Contains("name")) |
{ |
SelectXML = "<HFEA><Criteria PersonID='" + RadTreeView1.SelectedNode.Value + "'></Criteria></HFEA>"; |
} |
XmlDocument xDoc = MyWeb.GetObjectTemplate(798,SelectXML); |
return xDoc; |
} |
/// <summary> |
/// Gets the new staff data. |
/// </summary> |
/// <returns></returns> |
private XmlDocument GetNewStaffData() |
{ |
Centrepede.clsWebService MyWeb = new PortalFrontEnd.Centrepede.clsWebService(); |
string SelectXML = string.Empty; |
SelectXML = "<HFEA><Criteria PersonID='3'></Criteria></HFEA>"; |
XmlDocument xDoc = MyWeb.GetObjectTemplate(798, SelectXML); |
return xDoc; |
} |
/// <summary> |
/// Creates the staff panels. |
/// </summary> |
private void CreateStaffPanels() |
{ |
Centrepede.clsRenderer Builder = new PortalFrontEnd.Centrepede.clsRenderer(); |
Centrepede.clsWebService MyWeb = new PortalFrontEnd.Centrepede.clsWebService(); |
XmlDocument xTreeNodes = GetStaffData(); |
PlaceHolder1.Controls.Clear(); |
PlaceHolder1.Controls.Add(Builder.CreateGroupHeader(RadTreeView1.SelectedNode.Text)); |
//Base Holding Panel Bar Control |
RadPanelBar NewPanelBar = new RadPanelBar(); |
NewPanelBar.Width = Unit.Pixel(600); |
NewPanelBar.Height = Unit.Pixel(600); |
NewPanelBar.ExpandMode = PanelBarExpandMode.FullExpandedItem; |
bool FirstItem = true; |
bool ReadonlyMessage = false; |
foreach (XmlNode xNode in xTreeNodes.SelectNodes("HFEA/Object/Group")) |
{ |
RadPanelItem NewItem = new RadPanelItem(); |
NewItem.Text = xNode.Attributes["DisplayName"].Value.ToString(); |
RadPanelItem NewSubItem = new RadPanelItem(); |
if (FirstItem) |
{ |
NewItem.Expanded = true; |
FirstItem = false; |
} |
bool Readonly = false; |
if (xNode.Attributes["Readonly"].Value == "1") |
{ |
Readonly = true; |
} |
if (Readonly == true && ReadonlyMessage == false) |
{ |
string sMessage = "<Strong> Please Note : </Strong><br /> <p> You are unable to modify this member of staff as they are either HFEA members of staff , or the PR or NL, if you wish to modify them please contact the HFEA </p>"; |
NewSubItem.Controls.Add(new LiteralControl(sMessage)); |
ReadonlyMessage = true; |
} |
switch (xNode.Attributes["Type"].Value) |
{ |
case "List": |
Panel P1 = new Panel(); |
P1.Controls.Add(Builder.CreateListPanelFromXML(xNode, false)); |
P1.Controls.Add(CreateTableControlRow(xNode)); |
P1.Enabled = !Readonly; |
NewSubItem.Controls.Add(P1); |
break; |
case "Grid": |
NewSubItem.Controls.Add(CreateAddNewButton(xNode.Attributes["Name"].Value)); |
RadListView rTemp1 = CreateListViewFromXML(xNode); |
rTemp1.Enabled = !Readonly; |
NewSubItem.Controls.Add(rTemp1); |
break; |
case "DeepGrid": |
NewSubItem.Controls.Add(CreateAddNewButton(xNode.Attributes["Name"].Value)); |
RadListView rTemp2 = CreateListViewFromXML(xNode); |
rTemp2.Enabled = !Readonly; |
NewSubItem.Controls.Add(rTemp2); |
break; |
default: |
break; |
} |
NewItem.Items.Add(NewSubItem); |
NewPanelBar.Items.Add(NewItem); |
} |
PlaceHolder1.Controls.Add(NewPanelBar); |
} |
/// <summary> |
/// Creates the new staff panels. |
/// </summary> |
private void CreateNewStaffPanels() |
{ |
Centrepede.clsRenderer Builder = new PortalFrontEnd.Centrepede.clsRenderer(); |
Centrepede.clsWebService MyWeb = new PortalFrontEnd.Centrepede.clsWebService(); |
XmlDocument xTreeNodes = GetNewStaffData(); |
PlaceHolder1.Controls.Clear(); |
PlaceHolder1.Controls.Add(Builder.CreateGroupHeader("New Staff")); |
foreach (XmlNode xNode in xTreeNodes.SelectNodes("HFEA/Object/Group")) |
{ |
switch (xNode.Attributes["Type"].Value) |
{ |
case "List": |
PlaceHolder1.Controls.Add(Builder.CreateSubGroupHeader(xNode.Attributes["DisplayName"].Value)); |
PlaceHolder1.Controls.Add(Builder.CreateListPanelFromXML(xNode, false)); |
PlaceHolder1.Controls.Add(CreateTableControlRow(xNode)); |
break; |
default: |
break; |
} |
} |
} |
#region "Grid Functions" |
/// <summary> |
/// Handles the UpdateCommand event of the RadGrid1 control. |
/// </summary> |
/// <param name="source">The source of the event.</param> |
/// <param name="e">The <see cref="Telerik.Web.UI.GridCommandEventArgs"/> instance containing the event data.</param> |
void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) |
{ |
string ID = HttpContext.Current.Request.QueryString["ID"]; |
Centrepede.clsWebService MyWeb = new PortalFrontEnd.Centrepede.clsWebService(); |
XmlDocument xTemplate = GetStaffData(); |
GridEditFormItem Data = (GridEditFormItem)e.Item; |
DataSet MyDS = (DataSet)Data.OwnerTableView.DataSource; |
DataRow dr = MyDS.Tables[Data.OwnerTableView.DataMember].NewRow(); |
Hashtable ht = new Hashtable(); |
Data.ExtractValues(ht); |
PopulateHiddenValues(ref ht, xTemplate, Data); |
InsertEditGridData(ht, dr, Data.OwnerTableView.DataMember, xTemplate, "798"); |
Data.OwnerTableView.ClearEditItems(); |
xTemplate = GetStaffData(); |
Data.OwnerTableView.DataSource = GetBaseData(xTemplate); |
Data.OwnerTableView.DataBind(); |
MyWeb = null; |
e.Canceled = true; |
} |
/// <summary> |
/// Handles the InsertCommand event of the RadGrid1 control. |
/// </summary> |
/// <param name="source">The source of the event.</param> |
/// <param name="e">The <see cref="Telerik.Web.UI.GridCommandEventArgs"/> instance containing the event data.</param> |
void RadGrid1_InsertCommand(object source, GridCommandEventArgs e) |
{ |
string ID = HttpContext.Current.Request.QueryString["ID"]; |
XmlDocument xTemplate = GetStaffData(); |
Centrepede.clsRenderer Builder = new PortalFrontEnd.Centrepede.clsRenderer(); |
GridEditFormInsertItem Data = (GridEditFormInsertItem)e.Item; |
DataSet MyDS = (DataSet)Data.OwnerTableView.DataSource; |
DataRow dr = MyDS.Tables[Data.OwnerTableView.DataMember].NewRow(); |
Hashtable ht = new Hashtable(); |
Data.ExtractValues(ht); |
if (ht["PersonID"] == null) |
{ |
RadTextBox MyText = (RadTextBox)Builder.FindControlLike(PlaceHolder1.Controls, "PersonID"); |
ht.Add("PersonID", MyText.Text); |
} |
InsertEditGridData(ht, dr, Data.OwnerTableView.DataMember, xTemplate, ID); |
Data.OwnerTableView.IsItemInserted = false; |
xTemplate = GetStaffData(); |
Data.OwnerTableView.DataSource = GetBaseData(xTemplate); |
Data.OwnerTableView.DataBind(); |
e.Canceled = true; |
} |
/// <summary> |
/// Populates the hidden values. |
/// </summary> |
/// <param name="ht">The ht.</param> |
/// <param name="xTemplate">The x template.</param> |
/// <param name="gItem">The g item.</param> |
private void PopulateHiddenValues(ref Hashtable ht, XmlDocument xTemplate, GridEditFormItem gItem) |
{ |
XmlNode xGroup = xTemplate.SelectSingleNode("HFEA/Object/Group[@Name = '" + gItem.OwnerTableView.DataMember + "']"); |
foreach (XmlNode xControl in xGroup.SelectNodes("Controls")) |
{ |
if (xControl.Attributes["Type"].Value == "Hidden") |
{ |
string Name = xControl.Attributes["Name"].Value; |
if (gItem.ParentItem[Name] != null) |
{ |
string strHiddenField = gItem.ParentItem[Name].Text; |
ht.Add(Name, strHiddenField); |
} |
} |
} |
} |
/// <summary> |
/// Inserts the edit grid data. |
/// </summary> |
/// <param name="ht">The ht.</param> |
/// <param name="dr">The dr.</param> |
/// <param name="GroupName">Name of the group.</param> |
/// <param name="xTemplate">The x template.</param> |
/// <param name="ID">The ID.</param> |
/// <returns></returns> |
private bool InsertEditGridData(Hashtable ht, DataRow dr, string GroupName, XmlDocument xTemplate, string ID) |
{ |
Centrepede.clsWebService MyWeb = new PortalFrontEnd.Centrepede.clsWebService(); |
bool Updated = false; |
XmlNode xGroup = xTemplate.SelectSingleNode("HFEA/Object/Group[@Name = '" + GroupName + "']"); |
XmlNode xDataRow = xGroup.SelectSingleNode("Data[@ID = '" + ht["ID"] + "']"); |
//Record Exists |
if (xDataRow != null) |
{ |
foreach (DictionaryEntry entry in ht) |
{ |
//Console.WriteLine(entry.Key); |
//Console.WriteLine(entry.Value); |
if (xDataRow.Attributes[entry.Key.ToString()] != null) |
{ |
if (xDataRow.Attributes[entry.Key.ToString()].Value != entry.Value.ToString()) |
{ |
xDataRow.Attributes[entry.Key.ToString()].Value = entry.Value.ToString(); |
Updated = true; |
} |
} |
else |
{ |
if (entry.Value != null) |
{ |
XmlAttribute xAtt = xTemplate.CreateAttribute(entry.Key.ToString()); |
xAtt.Value = entry.Value.ToString(); |
xDataRow.Attributes.Append(xAtt); |
Updated = true; |
} |
} |
} |
if (Updated) |
{ |
XmlAttribute xAtt = xTemplate.CreateAttribute("Status"); |
xAtt.Value = "U"; |
xDataRow.Attributes.Append(xAtt); |
xGroup.ReplaceChild(xDataRow, xGroup.SelectSingleNode("Data[@ID = '" + ht["ID"] + "']")); |
xTemplate.SelectSingleNode("HFEA/Object").ReplaceChild(xGroup, xTemplate.SelectSingleNode("HFEA/Object/Group[@Name = '" + GroupName + "']")); |
} |
} |
else |
{ |
//New Record |
StringBuilder sb = new StringBuilder(); |
XmlWriterSettings Settings = new XmlWriterSettings(); |
Settings.OmitXmlDeclaration = true; |
XmlWriter xWrite = XmlWriter.Create(sb, Settings); |
xWrite.WriteStartElement("Data"); |
foreach (DictionaryEntry entry in ht) |
{ |
if (entry.Key.ToString() != "ID") |
{ |
if (entry.Value != null) |
{ |
xWrite.WriteAttributeString(entry.Key.ToString(), entry.Value.ToString()); |
} |
else |
{ |
xWrite.WriteAttributeString(entry.Key.ToString(), String.Empty); |
} |
} |
} |
xWrite.WriteEndElement(); |
xWrite.Close(); |
XmlDocument xNewDoc = new XmlDocument(); |
xNewDoc.LoadXml(sb.ToString()); |
XmlAttribute xAtt = xNewDoc.CreateAttribute("Status"); |
xAtt.Value = "I"; |
xNewDoc.FirstChild.Attributes.Append(xAtt); |
xGroup.AppendChild(xTemplate.ImportNode(xNewDoc.FirstChild, true)); |
Updated = true; |
} |
try |
{ |
if (Updated) |
{ |
MyWeb.UpdateObjectTemplate(798, xTemplate); |
} |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
return true; |
} |
#endregion |
#region "ListView" |
private Button CreateAddNewButton(string GroupName) |
{ |
Button NewButton = new Button(); |
NewButton.Text = "Add New"; |
NewButton.ID = "BTN" + GroupName; |
NewButton.CommandName = "InitInsert"; |
NewButton.Click += new EventHandler(NewButton_Click); |
return NewButton; |
} |
void NewButton_Click(object sender, EventArgs e) |
{ |
PortalFrontEnd.Centrepede.clsRenderer Builder = new PortalFrontEnd.Centrepede.clsRenderer(); |
string IDVal = ((Button)sender).ID.ToString(); |
IDValIDVal = IDVal.Replace("BTN", ""); |
RadListView NewList = (RadListView)Builder.FindControl(PlaceHolder1.Controls, IDVal); |
NewList.InsertItemPosition = RadListViewInsertItemPosition.FirstItem; |
(sender as Button).Visible = false; |
} |
private RadListView CreateListViewFromXML(XmlNode xDoc) |
{ |
return CreateList(xDoc); |
} |
private RadListView CreateList(XmlNode Template) |
{ |
RadListView MyList = new RadListView(); |
MyList.ID = Template.Attributes["Name"].Value; |
MyList.Width = Unit.Pixel(600); |
MyList.DataSource = GetBaseData(Template); |
MyList.DataMember = Template.Attributes["Name"].Value; |
MyList.LayoutTemplate = new LayoutTemplate(Template); |
MyList.ItemTemplate = new ItemTemplate(Template); |
MyList.AlternatingItemTemplate = new ItemTemplate(Template); |
MyList.EmptyDataTemplate = new EmptyDataTemplate(Template); |
MyList.EditItemTemplate = new EditItemTemplate(Template); |
MyList.InsertItemTemplate = new EditItemTemplate(Template); |
MyList.ItemPlaceholderID = "itemPlaceholder"; |
MyList.ItemInserted += new EventHandler<RadListViewInsertedEventArgs>(MyList_ItemInserted); |
MyList.ItemUpdated += new EventHandler<RadListViewUpdatedEventArgs>(MyList_ItemUpdated); |
MyList.ItemDeleted += new EventHandler<RadListViewDeletedEventArgs>(MyList_ItemDeleted); |
return MyList; |
} |
void MyList_ItemDeleted(object sender, RadListViewDeletedEventArgs e) |
{ |
throw new Exception("The method or operation is not implemented."); |
} |
void MyList_ItemUpdated(object sender, RadListViewUpdatedEventArgs e) |
{ |
throw new Exception("The method or operation is not implemented."); |
} |
void MyList_ItemInserted(object sender, RadListViewInsertedEventArgs e) |
{ |
throw new Exception("The method or operation is not implemented."); |
} |
#endregion |
#region "Table Functions" |
/// <summary> |
/// Creates the table control row. |
/// </summary> |
/// <param name="xControl">The x control.</param> |
/// <returns></returns> |
private Table CreateTableControlRow(XmlNode xControl) |
{ |
Table ControlTable = new Table(); |
ControlTable.BorderWidth = Unit.Pixel(0); |
TableRow ControlRow = new TableRow(); |
TableCell SaveCell = new TableCell(); |
SaveCell.BorderWidth = Unit.Pixel(0); |
SaveCell.HorizontalAlign = HorizontalAlign.Right; |
ControlRow.BorderWidth = Unit.Pixel(0); |
ControlTable.BorderWidth = Unit.Pixel(0); |
ImageButton SaveButton = new ImageButton(); |
SaveButton.Click += new ImageClickEventHandler(SaveButton_Click); |
SaveButton.CommandName = "Save"; |
SaveButton.ID = "btnSave"; |
SaveButton.Width = Unit.Pixel(72); |
SaveButton.Height = Unit.Pixel(25); |
SaveButton.ImageUrl = "img/site/buttons/btn-submit.png"; |
SaveCell.Controls.Add(SaveButton); |
ControlRow.Cells.Add(SaveCell); |
ControlTable.Rows.Add(ControlRow); |
return ControlTable; |
} |
/// <summary> |
/// Gets the screen data as xml for saving to the DB. |
/// </summary> |
/// <param name="xNode">The x node.</param> |
/// <param name="ObjectID">The object ID.</param> |
/// <returns></returns> |
private bool GetScreenData(ref XmlDocument xNode, string ObjectID) |
{ |
bool Updated = false; |
bool TreeUpdated = false; |
string RowKey = String.Empty; |
Centrepede.clsRenderer Builder = new PortalFrontEnd.Centrepede.clsRenderer(); |
XmlDocument xTemplate = xNode; |
foreach (XmlNode xGroupNode in xTemplate.SelectNodes("HFEA/Object/Group[@Type = 'List']")) |
{ |
string Name = xGroupNode.Attributes["Name"].Value; |
int RowCount = 0; |
bool newNode = false; |
XmlNode xData = xTemplate.CreateNode(XmlNodeType.Element, "Data", String.Empty); |
Updated = false; |
xData = xGroupNode.SelectSingleNode("Data"); |
if (xData == null) |
{ |
newNode = true; |
xData = xTemplate.CreateNode(XmlNodeType.Element, "Data", String.Empty); |
} |
foreach (XmlNode xControl in xGroupNode.SelectNodes("Controls")) |
{ |
RowCount++; |
RowKey = Name.GetHashCode() + RowCount.ToString(); |
System.Web.UI.Control Find = Builder.FindControl(PlaceHolder1.Controls, RowKey + xControl.Attributes["Name"].Value); |
string NewValue = String.Empty; |
if (Find != null) |
{ |
if (Find.ID == null) |
{ |
Find = null; |
} |
} |
if (Find != null) |
{ |
try |
{ |
Centrepede.clsRenderer.ControlTypes ControlType = (Centrepede.clsRenderer.ControlTypes)Enum.Parse(typeof(Centrepede.clsRenderer.ControlTypes), xControl.Attributes["Type"].Value); |
switch (ControlType) |
{ |
case Centrepede.clsRenderer.ControlTypes.Hidden: |
NewValue = ((RadTextBox)Find).Text; |
break; |
case Centrepede.clsRenderer.ControlTypes.Text: |
NewValue = ((RadTextBox)Find).Text; |
break; |
case Centrepede.clsRenderer.ControlTypes.Drop: |
NewValue = ((RadComboBox)Find).SelectedValue; |
break; |
case Centrepede.clsRenderer.ControlTypes.Date: |
NewValue = ((RadDatePicker)Find).SelectedDate.Value.ToString(); |
break; |
case Centrepede.clsRenderer.ControlTypes.Check: |
NewValue = Centrepede.clsCommon.TranslateBool(((CheckBox)Find).Checked); |
break; |
case Centrepede.clsRenderer.ControlTypes.Lookup: |
NewValue = ((HiddenField)Find).Value; |
break; |
case Centrepede.clsRenderer.ControlTypes.CheckList: |
NewValue = ((DayCheckList)Find).GetValues(); |
break; |
case Centrepede.clsRenderer.ControlTypes.Numeric: |
NewValue = ((RadNumericTextBox)Find).Text; |
break; |
case Centrepede.clsRenderer.ControlTypes.Label: |
NewValue = ((Label)Find).Text; |
break; |
} |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
if (xData.Attributes[xControl.Attributes["Name"].Value] != null) |
{ |
if (xData.Attributes[xControl.Attributes["Name"].Value].Value != NewValue) |
{ |
Updated = true; |
TreeUpdated = true; |
xData.Attributes[xControl.Attributes["Name"].Value].Value = NewValue; |
} |
} |
else |
{ |
XmlAttribute xNewAtt = xTemplate.CreateAttribute(xControl.Attributes["Name"].Value); |
xNewAtt.Value = NewValue; |
xData.Attributes.Append(xNewAtt); |
Updated = true; |
} |
} |
} |
if (Updated) |
{ |
if (xData.Attributes["Status"] == null) |
{ |
XmlAttribute xNewAtt = xTemplate.CreateAttribute("Status"); |
if (newNode) |
{ |
xNewAtt.Value = "I"; |
} |
else |
{ |
xNewAtt.Value = "U"; |
} |
xData.Attributes.Append(xNewAtt); |
} |
if (newNode) |
{ |
xGroupNode.AppendChild(xTemplate.ImportNode(xData, true)); |
} |
else |
{ |
xGroupNode.ReplaceChild(xData, xGroupNode.SelectSingleNode("Data")); |
} |
} |
} |
xNode = xTemplate; |
return TreeUpdated; |
} |
/// <summary> |
/// Handles the Click event of the SaveButton control. |
/// </summary> |
/// <param name="sender">The source of the event.</param> |
/// <param name="e">The <see cref="System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param> |
protected void SaveButton_Click(object sender, ImageClickEventArgs e) |
{ |
string NEW = Request.QueryString["New"]; |
Centrepede.clsWebService MyWeb = new PortalFrontEnd.Centrepede.clsWebService(); |
if (NEW != null) |
{ |
XmlDocument xTemplate = GetNewStaffData(); |
bool Changed = GetScreenData(ref xTemplate, String.Empty); |
XmlDocument xDoc = MyWeb.UpdateObjectTemplate(798, xTemplate); |
Response.Redirect("Staff.aspx?s=6&ID=" + xDoc.FirstChild.FirstChild.Attributes["ReturnValue"].Value); |
} |
else |
{ |
XmlDocument xTemplate = GetStaffData(); |
bool Changed = GetScreenData(ref xTemplate, String.Empty); |
MyWeb.UpdateObjectTemplate(798, xTemplate); |
Master.StatusLabel = "Update Completed"; |
} |
//Refresh Tree |
CreateStaffTree(); |
} |
#endregion |
} |
public class LayoutTemplate : ITemplate |
{ |
protected LiteralControl lControl; |
private XmlNode mLayoutDoc; |
public LayoutTemplate(XmlNode xLayoutDoc) |
{ |
mLayoutDoc = xLayoutDoc; |
} |
public void InstantiateIn(System.Web.UI.Control container) |
{ |
Panel HoldingPanel = new Panel(); |
Panel NewPanel = new Panel(); |
NewPanel.ID = "itemPlaceholder"; |
NewPanel.CssClass = "StaffPanel"; |
HoldingPanel.Controls.Add(NewPanel); |
container.Controls.Add(HoldingPanel); |
} |
} |
public class ItemTemplate : ITemplate |
{ |
protected LiteralControl lControl; |
private XmlNode mLayoutDoc; |
public ItemTemplate(XmlNode xLayoutDoc) |
{ |
mLayoutDoc = xLayoutDoc; |
} |
public void InstantiateIn(System.Web.UI.Control container) |
{ |
try |
{ |
RadAjaxPanel NewPanel = new RadAjaxPanel(); |
NewPanel.CssClass = "StaffPanel"; |
NewPanel.ID = "LayoutPanel"; |
PortalFrontEnd.Centrepede.clsRenderer Builder = new PortalFrontEnd.Centrepede.clsRenderer(); |
Table DisplayTable = new Table(); |
foreach (XmlNode xData in mLayoutDoc.SelectNodes("Controls")) |
{ |
TableRow NewRow = new TableRow(); |
NewRow.Cells.Add(CreateListLabelCell(xData)); |
TableCell DisplayCell = new TableCell(); |
Label DisplayInfo = new Label(); |
DisplayInfo.ID = xData.Attributes["Name"].Value; |
DisplayInfo.DataBinding += new EventHandler(DisplayInfo_DataBinding); |
switch (xData.Attributes["Type"].Value) |
{ |
case "Hidden": |
DisplayInfo.Visible = false; |
break; |
} |
DisplayCell.Controls.Add(DisplayInfo); |
NewRow.Cells.Add(DisplayCell); |
DisplayTable.Rows.Add(NewRow); |
} |
TableRow ControlRow = new TableRow(); |
TableCell Cell1 = new TableCell(); |
ImageButton imageButton = new ImageButton(); |
imageButton.ID = "EditButton"; |
imageButton.CommandName = RadListView.EditCommandName; |
imageButton.ImageUrl = "Img/site/buttons/Edit.gif"; |
Cell1.Controls.Add(imageButton); |
ImageButton DeleteButton = new ImageButton(); |
DeleteButton.ID = "DeleteButton"; |
DeleteButton.CommandName = RadListView.DeleteCommandName; |
DeleteButton.ImageUrl = "Img/site/buttons/Delete.gif"; |
Cell1.Controls.Add(DeleteButton); |
ControlRow.Cells.Add(Cell1); |
DisplayTable.Rows.Add(ControlRow); |
NewPanel.Controls.Add(DisplayTable); |
container.Controls.Add(NewPanel); |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
} |
void DisplayInfo_DataBinding(object sender, EventArgs e) |
{ |
Control_DataBinding(sender, e); |
} |
void Control_DataBinding(object sender, EventArgs e) |
{ |
try |
{ |
Label Control = (Label)sender; |
Control.Text = ((Control.NamingContainer as RadListViewDataItem).DataItem as DataRowView)[Control.ID].ToString(); |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
} |
private TableCell CreateListLabelCell(XmlNode xControl) |
{ |
TableCell LabelCell = new TableCell(); |
try |
{ |
Label MyLabel = new Label(); |
MyLabel.Style.Add("Align", "left"); |
MyLabel.Text = xControl.Attributes["Caption"].Value; |
MyLabel.Font.Bold = true; |
if (xControl.Attributes["Type"].Value == "Hidden") |
{ |
LabelCell.Visible = false; |
} |
LabelCell.Controls.Add(MyLabel); |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
return LabelCell; |
} |
} |
public class EmptyDataTemplate : ITemplate |
{ |
XmlNode mStore; |
public EmptyDataTemplate(XmlNode xNode) |
{ |
mStore = xNode; |
} |
public void InstantiateIn(System.Web.UI.Control container) |
{ |
Label label = new Label(); |
label.ID = "NoRecordsLabel"; |
label.Text = "No Records are available at this time"; |
container.Controls.Add(label); |
} |
} |
public class EditItemTemplate : ITemplate |
{ |
protected LiteralControl lControl; |
private XmlNode mLayoutDoc; |
public EditItemTemplate(XmlNode xLayoutDoc) |
{ |
mLayoutDoc = xLayoutDoc; |
} |
public void InstantiateIn(System.Web.UI.Control container) |
{ |
try |
{ |
RadAjaxPanel NewPanel = new RadAjaxPanel(); |
NewPanel.CssClass = "StaffEditPanel"; |
NewPanel.ID = "LayoutPanel"; |
PortalFrontEnd.Centrepede.clsRenderer Builder = new PortalFrontEnd.Centrepede.clsRenderer(); |
Table DisplayTable = new Table(); |
foreach (XmlNode xData in mLayoutDoc.SelectNodes("Controls")) |
{ |
TableRow NewRow = new TableRow(); |
if (xData.Attributes["Type"].Value != "Hidden") |
{ |
NewRow.Cells.Add(CreateListLabelCell(xData)); |
} |
switch (xData.Attributes["Type"].Value) |
{ |
case "Hidden": |
NewRow.Cells.Add(CreateTableTextCell(xData)); |
break; |
case "Text": |
NewRow.Cells.Add(CreateTableTextCell(xData)); |
break; |
case "Drop": |
NewRow.Cells.Add(CreateTableDropCell(xData)); |
break; |
case "Date": |
NewRow.Cells.Add(CreateTableDateCell(xData)); |
break; |
case "Check": |
NewRow.Cells.Add(CreateTableCheckCell(xData)); |
break; |
case "CheckList": |
NewRow.Cells.Add(CreateTableCheckListCell(xData)); |
break; |
case "Number": |
NewRow.Cells.Add(CreateTableTextCell(xData)); |
break; |
} |
DisplayTable.Rows.Add(NewRow); |
} |
TableRow ControlRow = new TableRow(); |
TableCell Cell1 = new TableCell(); |
ImageButton imageButton = new ImageButton(); |
imageButton.ID = "UpdateButton"; |
imageButton.CommandName = "Update"; |
imageButton.ImageUrl = "Img/site/buttons/Update.gif"; |
Cell1.Controls.Add(imageButton); |
ImageButton DeleteButton = new ImageButton(); |
DeleteButton.ID = "CancelButton"; |
DeleteButton.CommandName = "Cancel"; |
DeleteButton.ImageUrl = "Img/site/buttons/Cancel.gif"; |
Cell1.Controls.Add(DeleteButton); |
ControlRow.Cells.Add(Cell1); |
DisplayTable.Rows.Add(ControlRow); |
NewPanel.Controls.Add(DisplayTable); |
container.Controls.Add(NewPanel); |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
} |
private TableCell CreateListLabelCell(XmlNode xControl) |
{ |
TableCell LabelCell = new TableCell(); |
try |
{ |
Label MyLabel = new Label(); |
MyLabel.Width = Unit.Percentage(100); |
if (xControl.Attributes["DisplayName"] != null) |
{ |
MyLabel.Text = xControl.Attributes["DisplayName"].Value; |
} |
else |
{ |
MyLabel.Text = xControl.Attributes["Caption"].Value; |
} |
MyLabel.Font.Bold = true; |
LabelCell.Controls.Add(MyLabel); |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
return LabelCell; |
} |
private TableCell CreateTableTextCell(XmlNode xControl) |
{ |
TableCell TextTableCell = new TableCell(); |
try |
{ |
RadTextBox MyText = new RadTextBox(); |
MyText.ID = xControl.Attributes["Name"].Value; |
MyText.DataBinding += new EventHandler(Control_DataBinding); |
MyText.Height = Unit.Pixel(50); |
MyText.Width = Unit.Pixel(300); |
MyText.TextMode = InputMode.MultiLine; |
MyText.Wrap = true; |
if (xControl.Attributes["MaxLen"] != null) |
{ |
MyText.MaxLength = Convert.ToInt32(xControl.Attributes["MaxLen"].Value); |
} |
if (xControl.Attributes["Type"].Value == "Hidden") |
{ |
TextTableCell.Visible = false; |
} |
TextTableCell.Controls.Add(MyText); |
if (xControl.Attributes["Required"].Value == "1") |
{ |
RequiredFieldValidator Validator = new RequiredFieldValidator(); |
Validator.ErrorMessage = "* Required"; |
Validator.Text = "* Required"; |
Validator.ControlToValidate = xControl.Attributes["Name"].Value; |
TextTableCell.Controls.Add(Validator); |
} |
TextTableCell.Width = Unit.Pixel(300); |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
return TextTableCell; |
} |
private TableCell CreateTableDropCell(XmlNode xControl) |
{ |
TableCell DropTableCell = new TableCell(); |
try |
{ |
RadComboBox MyCombo = GetDropDownData(xControl.Attributes["Name"].Value, xControl); |
MyCombo.ID = xControl.Attributes["Name"].Value; |
MyCombo.Width = Unit.Pixel(300); |
MyCombo.DataBinding += new EventHandler(Control_DataBinding); |
DropTableCell.Controls.Add(MyCombo); |
if (xControl.Attributes["Required"].Value == "1") |
{ |
RequiredFieldValidator Validator = new RequiredFieldValidator(); |
Validator.ErrorMessage = "* Required"; |
Validator.Text = "* Required"; |
Validator.ControlToValidate = xControl.Attributes["Name"].Value; |
DropTableCell.Controls.Add(Validator); |
} |
DropTableCell.Width = Unit.Pixel(300); |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
return DropTableCell; |
} |
private RadComboBox GetDropDownData(string DropDownName, XmlNode Template) |
{ |
XmlNode xDropNode = Template; |
RadComboBox MyCombo = new RadComboBox(); |
try |
{ |
if (xDropNode != null) |
{ |
RadComboBoxItem NewItem2 = new RadComboBoxItem(); |
NewItem2.Text = xDropNode.Attributes["Caption"].Value; |
NewItem2.Value = ""; |
MyCombo.Items.Add(NewItem2); |
foreach (XmlNode xItem in xDropNode.ChildNodes) |
{ |
RadComboBoxItem NewItem = new RadComboBoxItem(); |
NewItem.Text = xItem.Attributes["Value"].Value; |
NewItem.Value = xItem.Attributes["ID"].Value; |
MyCombo.Items.Add(NewItem); |
} |
} |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
return MyCombo; |
} |
private TableCell CreateTableDateCell(XmlNode xControl) |
{ |
TableCell DateTableCell = new TableCell(); |
try |
{ |
RadDatePicker MyDate = new RadDatePicker(); |
MyDate.ID = xControl.Attributes["Name"].Value; |
MyDate.Width = Unit.Pixel(300); |
MyDate.DataBinding += new EventHandler(Control_DataBinding); |
DateTableCell.Width = Unit.Pixel(300); |
DateTableCell.Controls.Add(MyDate); |
if (xControl.Attributes["Required"].Value == "1") |
{ |
RequiredFieldValidator Validator = new RequiredFieldValidator(); |
Validator.ErrorMessage = "* Required"; |
Validator.Text = "* Required"; |
Validator.ControlToValidate = xControl.Attributes["Name"].Value; |
DateTableCell.Controls.Add(Validator); |
} |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
return DateTableCell; |
} |
private TableCell CreateTableCheckCell(XmlNode xControl) |
{ |
TableCell CheckTableCell = new TableCell(); |
try |
{ |
CheckBox MyCheck = new CheckBox(); |
MyCheck.ID = xControl.Attributes["Name"].Value; |
MyCheck.Width = Unit.Pixel(20); |
MyCheck.DataBinding += new EventHandler(Control_DataBinding); |
CheckTableCell.Width = Unit.Pixel(300); |
CheckTableCell.Controls.Add(MyCheck); |
if (xControl.Attributes["Required"].Value == "1") |
{ |
RequiredFieldValidator Validator = new RequiredFieldValidator(); |
Validator.ErrorMessage = "* Required"; |
Validator.Text = "* Required"; |
Validator.ControlToValidate = xControl.Attributes["Name"].Value; |
CheckTableCell.Controls.Add(Validator); |
} |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
return CheckTableCell; |
} |
private TableCell CreateTableCheckListCell(XmlNode xControl) |
{ |
TableCell CheckListCell = new TableCell(); |
try |
{ |
CheckListCell.Width = Unit.Pixel(300); |
DayCheckList MyCheckList = new DayCheckList(); |
MyCheckList.ID = xControl.Attributes["Name"].Value; |
MyCheckList.DataBinding += new EventHandler(Control_DataBinding); |
MyCheckList.PopulateControl(xControl); |
CheckListCell.Controls.Add(MyCheckList); |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
return CheckListCell; |
} |
void Control_DataBinding(object sender, EventArgs e) |
{ |
try |
{ |
XmlNode xControl = mLayoutDoc.SelectSingleNode("Controls[@Name = '" + ((Control)sender).ID + "']"); |
switch (xControl.Attributes["Type"].Value) |
{ |
case "Hidden": |
case "Text": |
case "Number": |
RadTextBox EditControl = (RadTextBox)sender; |
EditControl.Text = ((EditControl.NamingContainer as RadListViewDataItem).DataItem as DataRowView)[EditControl.ID].ToString(); |
break; |
case "Drop": |
RadComboBox MyCombo = (RadComboBox)sender; |
MyCombo.SelectedValue = ((MyCombo.NamingContainer as RadListViewDataItem).DataItem as DataRowView)[MyCombo.ID].ToString(); |
break; |
case "Date": |
RadDatePicker MyPicker = (RadDatePicker)sender; |
string DateValue = ((MyPicker.NamingContainer as RadListViewDataItem).DataItem as DataRowView)[MyPicker.ID].ToString(); |
MyPicker.SelectedDate = Convert.ToDateTime(DateValue); |
break; |
case "Check": |
CheckBox MyCheck = (CheckBox)sender; |
string Value = ((MyCheck.NamingContainer as RadListViewDataItem).DataItem as DataRowView)[MyCheck.ID].ToString(); |
MyCheck.Checked = Convert.ToBoolean(Value); |
break; |
case "CheckList": |
DayCheckList MyCheckList = (DayCheckList)sender; |
string CheckValue = ((MyCheckList.NamingContainer as RadListViewDataItem).DataItem as DataRowView)[MyCheckList.ID].ToString(); |
MyCheckList.PopulateValues(CheckValue); |
break; |
} |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
} |
} |
} |
i appreciate any assistance you can provide.
0
Hello Peter,
You should remove the RadAjaxPanels which are nested inside the items' templates. Also I have noticed that you are missing the NeedDataSource event handling, but instead simple data binding is used, which will not work correctly in such scenario.
Greetings,
Rosen
the Telerik team
You should remove the RadAjaxPanels which are nested inside the items' templates. Also I have noticed that you are missing the NeedDataSource event handling, but instead simple data binding is used, which will not work correctly in such scenario.
Greetings,
Rosen
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
0
Peter Maslin
Top achievements
Rank 1
answered on 02 Jul 2010, 02:47 PM
hi there
thanks alot for this that is exactly what i needed to know , i have changed it to use standard panels and it all works fine thank you very much for the speedy resolution.
thanks alot for this that is exactly what i needed to know , i have changed it to use standard panels and it all works fine thank you very much for the speedy resolution.
0
Peter Maslin
Top achievements
Rank 1
answered on 02 Jul 2010, 04:01 PM
ah well now thats shown another issue.
ive moved onto getting the data out from the edit panel etc , but the following returns no values :-
i have read in the forums about the runat=server command causing the problems , but as i am dynamically creating the templates etc i have no control over that , can you suggest a reason why the hash table would not return any values.
Peter.
ive moved onto getting the data out from the edit panel etc , but the following returns no values :-
void MyList_ItemCommand(object sender, RadListViewCommandEventArgs e) |
{ |
switch (e.CommandName) |
{ |
case RadListView.CancelCommandName: |
case RadListView.PerformInsertCommandName: |
((RadListView)sender).InsertItemPosition = RadListViewInsertItemPosition.None; |
break; |
case RadListView.UpdateCommandName: |
RadListViewEditableItem editedItem = (RadListViewEditableItem)e.ListViewItem; |
Hashtable newnewValues = new Hashtable(); |
editedItem.ExtractValues(newValues); |
i have read in the forums about the runat=server command causing the problems , but as i am dynamically creating the templates etc i have no control over that , can you suggest a reason why the hash table would not return any values.
Peter.
0
Accepted
Peter,
In order to extract values from a RadListViewDataItem it should implement IBindableTemplate instead of just ITemplate. You may take a look at this online demo.
Greetings,
Rosen
the Telerik team
In order to extract values from a RadListViewDataItem it should implement IBindableTemplate instead of just ITemplate. You may take a look at this online demo.
Greetings,
Rosen
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