or
<telerik:RadGrid ID="grdLogframe" OnNeedDataSource="grdLogframe_NeedDataSource" <br> OnItemDataBound="grdLogframe_ItemDataBound" OnPreRender="grdLogframe_PreRender" runat="server" AutoGenerateColumns="false"><br> <MasterTableView DataKeyNames="NodeID" Name="tblLogframe"><br> <Columns><br> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn><br> <telerik:GridBoundColumn UniqueName="NodeID" DataField="NodeID" Visible="false"></telerik:GridBoundColumn><br> <telerik:GridTemplateColumn UniqueName="NodeText" DataField="NodeText" HeaderText="Objectives"><br> <ItemTemplate><br> <%# Eval("ProjectLogframeNodeType.NodeTypeName") %> : <%# Eval("NodeText") %><br> </ItemTemplate><br> </telerik:GridTemplateColumn><br> <telerik:GridTemplateColumn UniqueName="indicators"><br> <itemtemplate><br> <telerik:RadGrid ID="grdIndicators" runat="server" AutoGenerateColumns="false" ShowHeader="true" OnPreRender="grdIndicators_PreRender" OnItemCreated="grdIndicators_ItemCreated" OnItemDataBound="grdIndicators_ItemDataBound"><br> <MasterTableView DataKeyNames="ProjectLogframeIndicatorID" <br> NoMasterRecordsText ="Indicators not defined yet" Name="tblIndicators"><br> <Columns><br> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn><br> <telerik:GridBoundColumn HeaderText="Project Indicators" UniqueName="Description" DataField="Description"></telerik:GridBoundColumn><br> <telerik:GridBoundColumn HeaderText="Corporate Indicators" UniqueName="CorpResultFrameworkIndicatorID" DataField="CorpResultFrameworkIndicatorID"></telerik:GridBoundColumn><br> <telerik:GridBoundColumn HeaderText="Programme Indicators" UniqueName="ProgrameIndicatorID" DataField="ProgrameIndicatorID"></telerik:GridBoundColumn><br> <telerik:GridBoundColumn HeaderText="Baseline" UniqueName="Baseline" DataField="Baseline"></telerik:GridBoundColumn><br> <telerik:GridBoundColumn HeaderText="Targets" UniqueName="Targets" DataField="Targets"></telerik:GridBoundColumn><br> <telerik:GridBoundColumn HeaderText="Means of Verifications" UniqueName="MeansOfVerification" DataField="MeansOfVerification"></telerik:GridBoundColumn><br> </Columns><br> <CommandItemSettings AddNewRecordText="Add Indicator" AddNewRecordImageUrl="../Img/insert.png" /><br> </MasterTableView><br> </telerik:RadGrid><br> </itemtemplate><br> </telerik:GridTemplateColumn>
...| Dim appid As String |
| Dim cblstr As String |
| Protected Sub SqlDataSource1_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Inserting |
| e.Command.Parameters("@AppID").Value = Applicants1.appid |
| e.Command.Parameters("@NotAvailalble").Value = cblstr |
| End Sub |
| Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting |
| If Applicants1.appid IsNot Nothing Then |
| appid = Applicants1.appid |
| e.Command.Parameters("@AppID").Value = appid |
| End If |
| End Sub |
| Protected Sub RadGrid1_EditCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.EditCommand |
| If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then |
| Dim cbl As CheckBoxList = (TryCast(e.Item, GridEditableItem)).Controls(0).FindControl("CBNotAvail") |
| ' this totally fails as it says it can't find the item |
| End If |
| End Sub |
| Protected Sub RadGrid1_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.InsertCommand |
| If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then |
| Dim cbl As CheckBoxList = (TryCast(e.Item, GridEditableItem)).Controls(0).FindControl("CBNotAvail") |
| cblstr = functions.CBListValues(cbl) |
| End If |
| End Sub |
| <telerik:GridTemplateColumn UniqueName="NotAvailable" HeaderText="Not Available" Visible="False"> |
| <EditItemTemplate> |
| <asp:CheckBoxList ID="CBNotAvail" runat="server" SelectedValue='<%# Bind("NotAvailalble") %>' > |
| <asp:ListItem>Monday</asp:ListItem> |
| <asp:ListItem>Tuesday</asp:ListItem> |
| </asp:CheckBoxList> |
| </EditItemTemplate> |
| </telerik:GridTemplateColumn> |
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ValidationEdit.aspx.cs" Inherits="EditPages_ValidationEdit" MasterPageFile="~/EUEMain.master" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><asp:Content ID="Content1" ContentPlaceHolderID="cphLeftNav" runat="Server"> <asp:HyperLink ID="HomeLink" runat="server" NavigateUrl="..\Default.aspx" Text="Home" /> <br /> <asp:HyperLink ID="AddLink" runat="server" Text="Status Edit Page" /> <br /></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="cphContent" runat="Server"> <p></p><p></p><p></p> <h1>Subdivision Statuses</h1> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager><telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings></telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" /> <telerik:RadGrid ID="RadGrid1" runat="server" DataModelID="Status" AllowPaging="True" AllowAutomaticUpdates="True" AllowAutomaticInserts="True" AllowAutomaticDeletes="true" AllowSorting="true" OnItemCreated="RadGrid1_ItemCreated" OnItemInserted="RadGrid1_ItemInserted" OnPreRender="RadGrid1_PreRender" OnInsertCommand="RadGrid1_InsertCommand" OnNeedDataSource="Radgrid1_NeedDataSource"> <PagerStyle Mode="NextPrevAndNumeric" /> <MasterTableView AutoGenerateColumns="False" DataKeyNames="Description" CommandItemDisplay="Top"> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description" UniqueName="Description" > </telerik:GridBoundColumn> <telerik:GridCheckBoxColumn DataField="Visible" HeaderText="Visible" SortExpression="Visible" UniqueName="Visible"> </telerik:GridCheckBoxColumn> <telerik:GridBoundColumn DataField="StatusType" HeaderText="Status Type" UniqueName="StatusType"></telerik:GridBoundColumn> <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton" /> </Columns> <EditFormSettings> <EditColumn ButtonType="ImageButton" /> </EditFormSettings> </MasterTableView> </telerik:RadGrid> <h1> Track Statuses <telerik:RadGrid ID="RadGrid2" runat="server" DataModelID="Status" AllowPaging="True" AllowAutomaticUpdates="True" AllowAutomaticInserts="True" AllowAutomaticDeletes="true" AllowSorting="true" OnItemCreated="RadGrid1_ItemCreated" OnItemInserted="RadGrid1_ItemInserted" OnPreRender="RadGrid1_PreRender" OnInsertCommand="RadGrid1_InsertCommand" OnNeedDataSource="Radgrid1_NeedDataSource"> <PagerStyle Mode="NextPrevAndNumeric" /> <MasterTableView AutoGenerateColumns="False" DataKeyNames="Description" CommandItemDisplay="Top"> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description" UniqueName="Description" > </telerik:GridBoundColumn> <telerik:GridCheckBoxColumn DataField="Visible" HeaderText="Visible" SortExpression="Visible" UniqueName="Visible"> </telerik:GridCheckBoxColumn> <telerik:GridBoundColumn DataField="StatusType" HeaderText="Status Type" UniqueName="StatusType"></telerik:GridBoundColumn> <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton" /> </Columns> <EditFormSettings> <EditColumn ButtonType="ImageButton" /> </EditFormSettings> </MasterTableView> </telerik:RadGrid> </h1> <asp:EntityDataSource ID="EntityDataSourceStatus" runat="server" ConnectionString="name=PtcDbModelEntities" DefaultContainerName="PtcDbModelEntities" EntitySetName="Status" OrderBy="it.[ContactName]" EntityTypeFilter="Description" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True"> </asp:EntityDataSource></asp:Content>using System;using System.Collections;using System.Collections.Generic;using System.Linq;using System.Web.UI;using Model;using Telerik.Web.UI;public partial class EditPages_ValidationEdit : BNSF.EUECommonApplication.EUEBasePage{ public List<Status> StatusList { get; set; } public object CurrentSubStatusList { get; set; } protected void Page_Load(object sender, EventArgs e) { AddLink.NavigateUrl = @"..\EditPages\ValidationEdit"; if (!Page.IsPostBack) { using (PtcDbModel localDb = new PtcDbModel()) { var localTemp = (from tempList in localDb.Status where tempList.StatusType == "S" select tempList) .ToList(); var localTemp2 = (from tempList in localDb.Status where tempList.StatusType == "T" select tempList) .ToList(); CurrentSubStatusList = localTemp; CurrentTrackStatusList = localTemp2; var tempDetailList = CurrentSubStatusList; var tempDetailList2 = CurrentTrackStatusList; RadGrid1.DataSource = tempDetailList; RadGrid2.DataSource = tempDetailList2; } } } public List<Status> CurrentTrackStatusList { get; set; } protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { if (!(e.Item is GridEditFormInsertItem)) { GridEditableItem item = e.Item as GridEditableItem; GridEditManager manager = item.EditManager; GridTextBoxColumnEditor editor = manager.GetColumnEditor("Description") as GridTextBoxColumnEditor; editor.TextBoxControl.Enabled = true; } } } protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e) { if (e.Exception != null) { e.ExceptionHandled = true; SetMessage("Customer cannot be inserted. Reason: " + e.Exception.Message); } else { SetMessage("New customer is inserted!"); } } private void DisplayMessage(string text) { RadGrid1.Controls.Add(new LiteralControl(string.Format("<span style='color:red'>{0}</span>", text))); } private void SetMessage(string message) { gridMessage = message; } private string gridMessage = null; protected void RadGrid1_PreRender(object sender, EventArgs e) { if (!string.IsNullOrEmpty(gridMessage)) { DisplayMessage(gridMessage); RadGrid1.DataBind(); RadGrid2.DataBind(); } } protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e) { if (e.Item is GridEditableItem) { GridEditableItem editedItem = e.Item as GridEditableItem; //here editedItem.SavedOldValues will be the dictionary which holds the //predefined values //Prepare new dictionary object Hashtable newValues = new Hashtable(); e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); //the newValues instance is the new collection of key -> value pairs //with the updated ny the user data } } protected void Radgrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { using (PtcDbModel localDb = new PtcDbModel()) { var localTemp = (from tempList in localDb.Status where tempList.StatusType == "S" select tempList) .ToList(); var localTemp2 = (from tempList in localDb.Status where tempList.StatusType == "T" select tempList) .ToList(); CurrentSubStatusList = localTemp; CurrentTrackStatusList = localTemp2; var tempDetailList = CurrentSubStatusList; var tempDetailList2 = CurrentTrackStatusList; RadGrid1.DataSource = tempDetailList; RadGrid2.DataSource = tempDetailList2; } }}
<telerik:RadGrid ID="RadGrid1" runat="server" ClientSettings-Selecting-AllowRowSelect="true" AutoGenerateColumns="False" AllowMultiRowSelection="true" OnNeedDataSource="RadGrid1_NeedDataSource" AllowMultiRowEdit="true"> <MasterTableView EditMode="Batch" DataKeyNames="Discipline_ID" CommandItemDisplay="Top"> <BatchEditingSettings EditType="Row" OpenEditingEvent="DblClick" /> <CommandItemTemplate> <asp:ImageButton ID="Button_Save" runat="server" ToolTip="Save" ImageUrl="~/dhtmlx/imgs/save.png" Height="20" Width="20" style="padding:5px 0 0 5px;" OnClick="Button_Save_Click" /> </CommandItemTemplate> <Columns> <telerik:GridBoundColumn DataField="Discipline_ID" Display="false" UniqueName="Discipline_ID"></telerik:GridBoundColumn> <telerik:GridClientSelectColumn UniqueName="SelectCheckBox" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="50px"></telerik:GridClientSelectColumn> <telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name" AllowSorting="true"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Description" HeaderText="Description" UniqueName="Description" AllowSorting="true"></telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:RadGrid>protected void Button_Save_Click(object sender, ImageClickEventArgs e) { foreach (GridDataItem item in RadGrid1.EditItems) { Hashtable newValues = new Hashtable(); item.OwnerTableView.ExtractValuesFromItem(newValues, item); } }
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ValidationEdit.aspx.cs" Inherits="EditPages_ValidationEdit" MasterPageFile="~/EUEMain.master" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><asp:Content ID="Content1" ContentPlaceHolderID="cphLeftNav" runat="Server"> <asp:HyperLink ID="HomeLink" runat="server" NavigateUrl="..\Default.aspx" Text="Home" /> <br /> <asp:HyperLink ID="AddLink" runat="server" Text="Status Edit Page" /> <br /></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="cphContent" runat="Server"> <h1>Subdivision Statuses</h1> <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> <asp:Label ID="Label1" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#FF8080"> </asp:Label> <asp:Label ID="Label2" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#00C000"> </asp:Label> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" /> <div id="Testing"> <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSourceSub" AllowPaging="True" AllowAutomaticUpdates="True" AllowAutomaticInserts="True" AllowAutomaticDeletes="true" AllowSorting="true" AutoGenerateColumns="False" OnItemUpdated="RadGrid1_ItemUpdated" OnPreRender="RadGrid1_PreRender" OnItemInserted="RadGrid1_ItemInserted"> <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="TopAndBottom" DataKeyNames="StatusId" DataSourceID="SqlDataSourceSub"> <Columns> <telerik:GridEditCommandColumn> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn DataField="StatusID" HeaderText="Status ID" UniqueName="StatusID" Visible="False" /> <telerik:GridBoundColumn DataField="StatusType" HeaderText="Status Type" UniqueName="StatusType" Visible="False" /> <telerik:GridBoundColumn DataField="Description" HeaderText="Description" UniqueName="Description" /> <telerik:GridCheckBoxColumn DataField="Visible" HeaderText="Visible" UniqueName="Visible" /> <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column" /> </Columns> <EditFormSettings EditFormType="Template"> <FormTemplate> <table id="table1"> <tr> <td>Subdivision Status Details</td> </tr> <tr> <td> <table id="Table2"> <tr> <td >Status ID</td> <td> <asp:Label runat="server" ID="StatusIdLabel" Text='<%#Bind("StatusId") %>' Visible="False"></asp:Label> </td> </tr> <tr> <td>Status Type</td> <td> <asp:TextBox runat="server" ID="StatusTypeTextBox" Text='<%#Bind("StatusType") %>'></asp:TextBox> </td> </tr> <tr> <td runat="server">Description</td> <td> <asp:TextBox runat="server" ID="DescriptionTextBox" Text='<%#Bind("Description") %>'></asp:TextBox> </td> </tr> <tr> <td>Visible</td> <td> <asp:CheckBox Checked='<%#Bind("Visible") %>' ID="VisibleCheckBox" runat="server" /> </td> </tr> <tr> <td> <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button> <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button> </td> </tr> </table> </td> </tr> </table> </FormTemplate> </EditFormSettings> </MasterTableView> </telerik:RadGrid> </div> <asp:SqlDataSource ID="SqlDataSourceSub" runat="server" ConnectionString="<%$ ConnectionStrings:PtcDbModelEntities %>" DeleteCommand="DELETE FROM [dbo].[Status] WHERE [StatusId] = @StatusId" InsertCommand="INSERT INTO [dbo].[Status] ([StatusType], [Description], [Visible], VALUES (@StatusType, @Description, @BitVisible)" SelectCommand="SELECT [StatusId], [StatusType], [Visible], [Description] FROM [dbo].[Status] where StatusType = 'S'" UpdateCommand="UPDATE [dbo].[Status] SET [StatusType] = @StatusType, [Description] = @Description, Visible = @Visible WHERE [StatusId] = @StatusId"> <DeleteParameters> <asp:Parameter Name="StatusId" Type="Int32"></asp:Parameter> </DeleteParameters> <InsertParameters> <asp:Parameter Name="StatusType" Type="String"></asp:Parameter> <asp:Parameter Name="Description" Type="String"></asp:Parameter> <asp:Parameter Name="Visible" Type="Boolean"></asp:Parameter> </InsertParameters> <UpdateParameters> <asp:Parameter Name="StatusType" Type="String"></asp:Parameter> <asp:Parameter Name="Description" Type="String"></asp:Parameter> <asp:Parameter Name="Visible" Type="Boolean"></asp:Parameter> <asp:Parameter Name="StatusId" Type="Int32" /> </UpdateParameters> </asp:SqlDataSource>using System;using System.Web.UI.WebControls;using Telerik.Web.UI;public partial class EditPages_ValidationEdit : BNSF.EUECommonApplication.EUEBasePage{ protected void Page_Load(object sender, EventArgs e) { AddLink.NavigateUrl = @"..\EditPages\ValidationEdit.aspx"; } protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e) { SqlDataSourceSub.UpdateParameters["Description"].DefaultValue = e.ToString(); SqlDataSourceSub.UpdateParameters["StatusType"].DefaultValue = e.ToString(); SqlDataSourceSub.UpdateParameters["Visible"].DefaultValue = e.ToString(); if (e.Exception != null) { e.KeepInEditMode = true; e.ExceptionHandled = true; DisplayMessage(true, "Status " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["StatusId"] + " cannot be updated. Reason: " + e.Exception.Message); } else { DisplayMessage(false, "Status " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["StatusId"] + " updated"); } } protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e) { SqlDataSourceSub.InsertParameters["StatusType"].DefaultValue = e.ToString(); SqlDataSourceSub.InsertParameters["Description"].DefaultValue = e.ToString(); SqlDataSourceSub.InsertParameters["Visible"].DefaultValue = e.ToString(); } protected void RadGrid1_ItemDeleted(object source, GridDeletedEventArgs e) { if (e.Exception != null) { e.ExceptionHandled = true; DisplayMessage(true, "Status " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["StatusId"] + " cannot be deleted. Reason: " + e.Exception.Message); } else { DisplayMessage(false, "Status " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["StatusId"] + " deleted"); } } private void DisplayMessage(bool isError, string text) { Label label = (isError) ? this.Label1 : this.Label2; label.Text = text; } protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked { GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); editColumn.Visible = false; } else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) { e.Canceled = true; } else { GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); if (!editColumn.Visible) editColumn.Visible = true; } } protected void RadGrid1_PreRender(object sender, EventArgs e) { if (!Page.IsPostBack) { RadGrid1.EditIndexes.Add(0); RadGrid1.Rebind(); } }}