Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
64 views

Telerik RadDatePicker unable to choose selected date from calendar using Firefox(39.0) and Chrome(43.0.2357.134) but Same is worked for IE(9.0). We are using framework 2.0 with visual studio 2005.

 

 <radCln:RadDatePicker ID="radFromDate" MinDate="1/Jan/1900" onkeypress="javaScript: return false;"
                                                                        DateInput-DateFormat="dd-MMM-yyyy" DateInput-DisplayDateFormat="dd-MMM-yyyy"
                                                                        AutoPostBack="true" runat="server" Width="130px" Visible="false"           OnSelectedDateChanged="radIDFromDate_OnSelectedDateChanged">
                                                                    </radCln:RadDatePicker>​

Eyup
Telerik team
 answered on 24 Jul 2015
1 answer
135 views
                                <div id="divStuff" runat="server" Visible="False"
                                    style="float: left; position: relative; padding-top: 5px; padding-left: 25px; height: 340px; width: 500px; margin-right: 2px" >
                                    <fieldset style="height: 350px">
                                        <legend><b>Names</b></legend>
                                        <div style="padding-top: 25px; padding-left: 15px">
                                            <div style="float: left;padding-left: 40px">
                                                <div>
                                                    <asp:Label runat="server" Text="Available" Font-Bold="True"></asp:Label>
                                                </div>
                     <telerik:RadListBox id="lstAvailableNames"
                                                    AllowTransfer="true" TransferToID="lstSelectedNames" AllowReorder="True" ButtonSettings-AreaWidth="35px"
                                                    TransferMode="Move" SelectionMode="Multiple" Sort="Ascending"
                      runat="server" Height="260px" Width="185px" AutoPostBackOnTransfer="True"
                                                    OnTransferred="OnListBoxTransferred">
                     </telerik:RadListBox>
                                            </div>
                                            <div style="float: left">
                                                <div>
                                                <asp:Label runat="server" Text="Selected" Font-Bold="True"></asp:Label>
                                                </div>
                     <telerik:RadListBox  id="lstSelectedNames" SelectionMode="Multiple"
                                                    ButtonSettings-AreaWidth="35px" Sort="Ascending"
                      runat="server" Height="260px" Width="155px" >
                     </telerik:RadListBox>
                                            </div>
                                        </div>
                                    </fieldset>
                                </div>
Aneliya Petkova
Telerik team
 answered on 24 Jul 2015
1 answer
218 views

Following is code....

1.Drawing a line with multiple values.

 <telerik:RadHtmlChart runat="server" ID="chart1" Width="800" Height="500" Transitions="true">
    <PlotArea>
        <Series>
        
            <telerik:LineSeries Name="Line Series">
                <LineAppearance LineStyle="Step" />
                <Appearance>
                    <FillStyle BackgroundColor="Green" />
                </Appearance>
                <LabelsAppearance Visible="false" />
                <MarkersAppearance Visible="false" />
                <SeriesItems>
                    <telerik:CategorySeriesItem Y="200" />
                    <telerik:CategorySeriesItem Y="200" />
                    <telerik:CategorySeriesItem Y="200" />
                    <telerik:CategorySeriesItem Y="200" />
                    <telerik:CategorySeriesItem Y="200" />
                    <telerik:CategorySeriesItem Y="200" />
                    <telerik:CategorySeriesItem Y="200" />
                </SeriesItems>
            </telerik:LineSeries>
        </Series>
        <CommonTooltipsAppearance Color="White"></CommonTooltipsAppearance>
        <XAxis>
            <MajorGridLines Color="#EFEFEF" Width="1" />
            <MinorGridLines Color="#F7F7F7" Width="1" />
            <Items>
                <telerik:AxisItem LabelText="2008" />
                <telerik:AxisItem LabelText="2009" />
                <telerik:AxisItem LabelText="2010" />
                <telerik:AxisItem LabelText="2011" />
                <telerik:AxisItem LabelText="2012" />
                <telerik:AxisItem LabelText="2013" />
                <telerik:AxisItem LabelText="2014" />
            </Items>
            <TitleAppearance Position="Center" Text="Years" />
        </XAxis>
        <YAxis>
            <MajorGridLines Color="#EFEFEF" Width="1" />
            <MinorGridLines Color="#F7F7F7" Width="1" />
            <TitleAppearance Position="Center" Text="Finance" />
        </YAxis>
    </PlotArea>
    <ChartTitle Text="Company Performance">
        <Appearance Align="Center" Position="Top" />
    </ChartTitle>
    <Legend>
        <Appearance Position="Bottom" />
    </Legend>
</telerik:RadHtmlChart>

 

2.Not drawing a line with single value.

<telerik:RadHtmlChart runat="server" ID="chart1" Width="800" Height="500" Transitions="true">
    <PlotArea>
        <Series>
        
            <telerik:LineSeries Name="Line Series">
                <LineAppearance LineStyle="Step" />
                <Appearance>
                    <FillStyle BackgroundColor="Green" />
                </Appearance>
                <LabelsAppearance Visible="false" />
                <MarkersAppearance Visible="false" />
                <SeriesItems>
                    <telerik:CategorySeriesItem Y="200" />                  
                </SeriesItems>
            </telerik:LineSeries>
        </Series>
        <CommonTooltipsAppearance Color="White"></CommonTooltipsAppearance>
        <XAxis>
            <MajorGridLines Color="#EFEFEF" Width="1" />
            <MinorGridLines Color="#F7F7F7" Width="1" />
            <Items>
                <telerik:AxisItem LabelText="2008" />
                <telerik:AxisItem LabelText="2009" />
                <telerik:AxisItem LabelText="2010" />
                <telerik:AxisItem LabelText="2011" />
                <telerik:AxisItem LabelText="2012" />
                <telerik:AxisItem LabelText="2013" />
                <telerik:AxisItem LabelText="2014" />
            </Items>
            <TitleAppearance Position="Center" Text="Years" />
        </XAxis>
        <YAxis>
            <MajorGridLines Color="#EFEFEF" Width="1" />
            <MinorGridLines Color="#F7F7F7" Width="1" />
            <TitleAppearance Position="Center" Text="Finance" />
        </YAxis>
    </PlotArea>
    <ChartTitle Text="Company Performance">
        <Appearance Align="Center" Position="Top" />
    </ChartTitle>
    <Legend>
        <Appearance Position="Bottom" />
    </Legend>
</telerik:RadHtmlChart>

 

Please find the attached files.​

 

Danail Vasilev
Telerik team
 answered on 24 Jul 2015
1 answer
175 views
I am able to draw a line between two series but not able to draw on single series it is showing only point. I want draw line single series also.
Danail Vasilev
Telerik team
 answered on 24 Jul 2015
1 answer
68 views

I think this is an advance topic in Kendo UI. I have a Kendo UI grid and I added a custom edit popup to update the data in the grid.
My data packet like this :

 

{
 fieldOne : "valueOne";
 fieldTwo : "valueTwo";
 fieldThree : [{a : "someValue", b : "someValue"},{a : "someValue", b : "someValue"}]
}
 

 In edit popup I will edit this data. But I have a new requirement that add a new value to fieldThree. My new Data packet will look like this...     

 {
  fieldOne : "valueOne";
  fieldTwo : "valueTwo";
  fieldThree : [{a : "someValue", b : "someValue"}]
 }

 

 

 

What I have done is I made a custom popup and custom fields for that. But my question is how I redefine the data packet to above one ?? In Kendo UI it will only update existing values...

 

Rasika
Top achievements
Rank 1
 answered on 24 Jul 2015
1 answer
91 views

 

How to display single RadGrid as like below :

 

1).if i click on Addnew Record button, RadGrid should display all Columns (Example: 10 cols) in EditForms mode only for Insert

        

2).if i click on Edit Button, RadGrid should display 4 columns (remaining should be hide) in Inplace mode only for Update

 

 

 

 

Eyup
Telerik team
 answered on 24 Jul 2015
1 answer
129 views
i followed the link 
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/automatic-datasource-operations to created RadGrid control. i would like to add hyperlink to all the columns so that it will open up a page or a small popup with the row.
I have managed the popup with RadWindowManager. Now the only thing left out is adding hyperlink to the cells of a databound Grid.
 the below code does not work for me please help


protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        HyperLink link = new HyperLink();
        link.Attributes["href"] = "javascript:void(0);";
        link.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"], e.Item.ItemIndex);
        //link.NavigateUrl = "Page.aspx";//for navigating to new page
        //link.CssClass = "class1";//for showing underline in hyperlink
        link.Text = item.GetDataKeyValue("ID").ToString();
        item["ID"].Controls.Add(link);
    }
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{


    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        HyperLink link = new HyperLink();
        link.Attributes["href"] = "javascript:void(0);";
        link.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"], e.Item.ItemIndex);
        item["ID"].Controls.Add(link);
    }


}

please see the code 
Aspx of Default

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" namespace="System.Web.UI.WebControls" tagprefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head id="Head1" runat="server">
    <title>Telerik ASP.NET Example</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server">
    </telerik:RadStyleSheetManager>
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
      <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
      <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
</telerik:RadWindowManager>
        <script type="text/javascript">
            function ShowEditForm(id, rowIndex) {
                var grid = $find("<%= RadGrid1.ClientID %>");

                var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
                grid.get_masterTableView().selectItem(rowControl, true);

                window.radopen("EditForm_csharp.aspx?ID=" + id, "UserListDialog");
                return false;
            }
//            function ShowInsertForm() {
//                window.radopen("EditForm_csharp.aspx");
//                return false;
//            }
            function refreshGrid(arg) {
                if (!arg) {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                }
                else {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
                }
            }
            function RowDblClick(sender, eventArgs) {
                window.radopen("EditForm_csharp.aspx?EmployeeID=" + eventArgs.getDataKeyValue("EmployeeID"), "UserListDialog");
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"LoadingPanelID="gridLoadingPanel"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"LoadingPanelID="gridLoadingPanel"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
    <telerik:RadFormDecorator runat="server" DecorationZoneID="demo" EnableRoundedCorners="false"DecoratedControls="All" />
    <div id="demo" class="demo-container no-bg">
        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource2"
            AllowPaging="True" AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
            AllowAutomaticDeletes="True" OnItemCreated="RadGrid1_ItemCreated"
            OnItemInserted="RadGrid1_ItemInserted" OnPreRender="RadGrid1_PreRender"
            OnInsertCommand="RadGrid1_InsertCommand" GroupPanelPosition="Top"
            ResolvedRenderMode="Classic"
            EnableViewState="False" ShowGroupPanel="True" AllowMultiRowEdit="True"
            AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True">
            <PagerStyle Mode="NextPrevAndNumeric" />
            <ClientSettings AllowDragToGroup="True">
                <Selecting AllowRowSelect="True" />
                <Scrolling AllowScroll="True" UseStaticHeaders="True" />
            </ClientSettings>
            <MasterTableView DataSourceID="SqlDataSource2"
            AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="ID" >
                <Columns>

                    <telerik:GridBoundColumn DataField="Self_development"
                        HeaderText="Self_development" SortExpression="Self_development"
                        UniqueName="Self_development"
                        FilterControlAltText="Filter Self_development column" >
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Technical_Development"
                        HeaderText="Technical_Development" SortExpression="Technical_Development"
                        UniqueName="Technical_Development"
                        FilterControlAltText="Filter Technical_Development column" >
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Project_Management"
                        HeaderText="Project_Management" SortExpression="Project_Management"
                        UniqueName="Project_Management"
                        FilterControlAltText="Filter Project_Management column" >
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Safety"
                        HeaderText="Safety" SortExpression="Safety"
                        UniqueName="Safety"
                        FilterControlAltText="Filter Safety column" >
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Client_Relationship"
                        HeaderText="Client_Relationship" SortExpression="Client_Relationship"
                        UniqueName="Client_Relationship" FilterControlAltText="Filter Client_Relationship column"
                        >
                    </telerik:GridBoundColumn>
                    <%--<telerik:GridHyperLinkColumn DataTextFormatString="Search Google for '{0}'"DataNavigateUrlFields="Client_Relationship"
                    UniqueName="Client_Relationship"DataNavigateUrlFormatString="http://www.google.com/search?hl=en&;q={0}&btnG=Google+Search"
                    DataTextField="Client_Relationship">
                    </telerik:GridHyperLinkColumn>--%>
                <telerik:GridBoundColumn DataField="Leadership_Development"
                        FilterControlAltText="Filter Leadership_Development column"
                        HeaderText="Leadership_Development"
                        SortExpression="Leadership_Development"UniqueName="Leadership_Development"></telerik:GridBoundColumn><telerik:GridBoundColumn
                        DataField="ID" DataType="System.Int32" FilterControlAltText="Filter ID column"
                        HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID"></telerik:GridBoundColumn>
                        <telerik:GridTemplateColumn UniqueName="TemplateEditColumn">
                    <ItemTemplate>
                        <asp:HyperLink ID="EditLink" runat="server" Text="Edit"></asp:HyperLink>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                        </Columns>
                    <%--     <CommandItemTemplate>
                <a href="#" onclick="return ShowInsertForm();">Add New Record</a>
            </CommandItemTemplate>--%>
                <EditFormSettings>
                    <EditColumn ButtonType="ImageButton" />
<EditColumn ButtonType="ImageButton"></EditColumn>
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>
    </div>
    <%--<asp:EntityDataSource ID="EntityDataSourceCustomers" runat="server"ConnectionString="name=NorthwindReadWriteEntities"
        DefaultContainerName="NorthwindReadWriteEntities" EntitySetName="Customers" OrderBy="it.[ContactName]"
        EntityTypeFilter="Customer" EnableDelete="True" EnableFlattening="False" EnableInsert="True"EnableUpdate="True">
    </asp:EntityDataSource>--%>
    <asp:EntityDataSource ID="EntityDataSource1" runat="server"
        ConnectionString="name=LMSDBEntities3" DefaultContainerName="LMSDBEntities3"
        EntitySetName="Course_mainPage"
        OrderBy="it.[Self_development]"


        EnableDelete="True" EnableInsert="True" EnableUpdate="True" >
    </asp:EntityDataSource>



 <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:LMSDBConnectionString %>"
   SelectCommand="SELECT [Self_development] ,[Technical_Development] ,[Project_Management] ,[Safety] ,[Client_Relationship] ,[Leadership_Development] ,[ID] FROM [LMSDB].[dbo].[Course_mainPage]"
   DeleteCommand="DELETE FROM Course_mainPage WHERE (ID = @ID)"
   InsertCommand="INSERT INTO Course_mainPage(Self_development, Technical_Development, Project_Management, Safety, Client_Relationship, Leadership_Development) VALUES (@Self_development,@Technical_Development,@Project_Management,@Safety,@Client_Relationship,@Leadership_Development)"



        UpdateCommand="UPDATE Course_mainPage SET Self_development = @Self_development, Technical_Development = @Technical_Development, Project_Management = @Project_Management, Safety = @Safety, Client_Relationship = @Client_Relationship, Leadership_Development = @Leadership_Development WHERE (ID = @ID)">
   <DeleteParameters>
       <asp:Parameter Name="ID" Type="Int32" />
   </DeleteParameters>
    <InsertParameters>
       <asp:Parameter Name="Self_development" />
       <asp:Parameter Name="Technical_Development" />
       <asp:Parameter Name="Project_Management" />
       <asp:Parameter Name="Safety" />
       <asp:Parameter Name="Client_Relationship" />
       <asp:Parameter Name="Leadership_Development" />
   </InsertParameters>

    <UpdateParameters>
      <asp:Parameter Name="Self_development" />
       <asp:Parameter Name="Technical_Development" />
       <asp:Parameter Name="Project_Management" />
       <asp:Parameter Name="Safety" />
       <asp:Parameter Name="Client_Relationship" />
       <asp:Parameter Name="Leadership_Development" />
        <asp:Parameter Name="ID" />
    </UpdateParameters>
 </asp:SqlDataSource>


   <%--
 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:LMSDBConnectionString %>"
   SelectCommand="SELECT [Self_development] ,[Technical_Development] ,[Project_Management] ,[Safety] ,[Client_Relationship] ,[Leadership_Development] ,[ID] FROM [LMSDB].[dbo].[Course_mainPage]"
   DeleteCommand="DELETE FROM Course_mainPage WHERE (ID = @ID)"
   InsertCommand="INSERT INTO Course_mainPage(Self_development, Technical_Development, Project_Management, Safety, Client_Relationship, Leadership_Development) VALUES (@Self_development,@Technical_Development,@Project_Management,@Safety,@Client_Relationship,@Leadership_Development)"

        UpdateCommand="UPDATE Course_mainPage SET Self_development =@Self_development, Technical_Development =@Technical_Development, Project_Management =@Project_Management, Safety =@Safety, Client_Relationship =@Client_Relationship, Leadership_Development =@Leadership_Development where [ID] = @ID">
   <DeleteParameters>
       <asp:Parameter Name="ID" Type="Int32" />
   </DeleteParameters>
    <InsertParameters>
       <asp:Parameter Name="@Self_development" Type="String" />
       <asp:Parameter Name="@Technical_Development" Type="String" />
       <asp:Parameter Name="@Project_Management" Type="String" />
       <asp:Parameter Name="@Safety" Type="String" />
       <asp:Parameter Name="@Client_Relationship" Type="String" />
       <asp:Parameter Name="@Leadership_Development" Type="String" />
   </InsertParameters>

    <UpdateParameters>
      <asp:Parameter Name="@Self_development" Type="String" />
       <asp:Parameter Name="@Technical_Development" Type="String" />
       <asp:Parameter Name="@Project_Management" Type="String" />
       <asp:Parameter Name="@Safety" Type="String" />
       <asp:Parameter Name="@Client_Relationship" Type="String" />
       <asp:Parameter Name="@Leadership_Development" Type="String" />
       <asp:Parameter Name="@ID" Type="Int32" />
    </UpdateParameters>
 </asp:SqlDataSource>
  --%>

   <%-- Select="it.[Self_development], it.[Technical_Development], it.[Project_Management], it.[Client_Relationship], it.[Safety], it.[Leadership_Development], it.[ID]" --%>
    </form>
</body>
</html>

C# of default


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Telerik.Web.UI;
using System.Collections;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    //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("ID") as GridTextBoxColumnEditor;
    //            editor.TextBoxControl.Enabled = false;
    //        }
    //    }     
    //}
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        //if (e.Item is GridDataItem)
        //{
        //    HyperLink editLink = (HyperLink)e.Item.FindControl("EditLink");
        //editLink.Attributes["href"] = "javascript:void(0);";
        //editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"], e.Item.ItemIndex);
        //}



        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            HyperLink link = new HyperLink();
            link.Attributes["href"] = "javascript:void(0);";
            link.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"], e.Item.ItemIndex);
            //link.NavigateUrl = "Page.aspx";//for navigating to new page
            //link.CssClass = "class1";//for showing underline in hyperlink
            link.Text = item.GetDataKeyValue("ID").ToString();
            item["ID"].Controls.Add(link);
        }
    }
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {


        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            HyperLink link = new HyperLink();
            link.NavigateUrl = "Page.aspx";//for navigating to new page
            link.CssClass = "class1";//for showing underline in hyperlink
            link.Text = item.GetDataKeyValue("ID").ToString();
            item["ID"].Controls.Add(link);
        }


    }
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "Rebind")
        {
            RadGrid1.MasterTableView.SortExpressions.Clear();
            RadGrid1.MasterTableView.GroupByExpressions.Clear();
            RadGrid1.Rebind();
        }
        else if (e.Argument == "RebindAndNavigate")
        {
            RadGrid1.MasterTableView.SortExpressions.Clear();
            RadGrid1.MasterTableView.GroupByExpressions.Clear();
            RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1;
            RadGrid1.Rebind();
        }
    }

    protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e)
    {
        if (e.Exception != null)
        {

            e.ExceptionHandled = true;
            SetMessage("Record cannot be inserted. Reason: " + e.Exception.Message);

        }
        else
        {
            SetMessage("New Record 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);
        }
    }

    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
        }
    }
}
aspx of Editform_csharp.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Editform_csharp.aspx.cs" Inherits="Editform_csharp" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Edit dialog</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <script type="text/javascript">
            function CloseAndRebind(args) {
                GetRadWindow().BrowserWindow.refreshGrid(args);
                GetRadWindow().close();
            }

            function GetRadWindow() {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)

                return oWindow;
            }

            function CancelEdit() {
                GetRadWindow().close();
            }
        </script>
        <asp:ScriptManager ID="ScriptManager2" runat="server" />
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Vista" DecoratedControls="All"/>
        <br />
        <br />
        <asp:DetailsView ID="DetailsView1" DataKeyNames="ID" runat="server" AutoGenerateRows="False"
            DataSourceID="SqlDataSource2" Height="50px" Width="125px"OnItemCommand="DetailsView1_ItemCommand"
            BorderWidth="0px" CellPadding="0" CellSpacing="7" GridLines="None"
            OnItemUpdating="DetailsView1_ItemUpdating"
            onpageindexchanging="DetailsView1_PageIndexChanging" AllowPaging="True"
            EnableModelValidation="True">
            <Fields>
                <asp:BoundField DataField="Self_development" HeaderText="Self_development"SortExpression="Self_development" />
                <asp:BoundField DataField="Technical_Development" HeaderText="Technical_Development"SortExpression="Technical_Development" />
                <asp:BoundField DataField="Project_Management" HeaderText="Project_Management"SortExpression="Project_Management" />
<asp:BoundField DataField="Safety" HeaderText="Safety" SortExpression="Safety"></asp:BoundField>
                <asp:BoundField DataField="Client_Relationship"
                    HeaderText="Client_Relationship" SortExpression="Client_Relationship" />
                <asp:BoundField DataField="Leadership_Development"
                    HeaderText="Leadership_Development" SortExpression="Leadership_Development" />
            <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID"
                    InsertVisible="False" ReadOnly="True" />
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
                    ShowInsertButton="True" />
            </Fields>
        </asp:DetailsView>


       <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:LMSDBConnectionString %>"
       SelectCommand="SELECT [Self_development] ,[Technical_Development] ,[Project_Management] ,[Safety] ,[Client_Relationship] ,[Leadership_Development] ,[ID] FROM [LMSDB].[dbo].[Course_mainPage]"
       DeleteCommand="DELETE FROM Course_mainPage WHERE (ID = @ID)"
       InsertCommand="INSERT INTO Course_mainPage(Self_development, Technical_Development, Project_Management, Safety, Client_Relationship, Leadership_Development) VALUES (@Self_development,@Technical_Development,@Project_Management,@Safety,@Client_Relationship,@Leadership_Development)"



       UpdateCommand="UPDATE Course_mainPage SET Self_development = @Self_development, Technical_Development = @Technical_Development, Project_Management = @Project_Management, Safety = @Safety, Client_Relationship = @Client_Relationship, Leadership_Development = @Leadership_Development WHERE (ID = @ID)">
       <DeleteParameters>
       <asp:Parameter Name="ID" Type="Int32" />
       </DeleteParameters>
       <InsertParameters>
           <asp:Parameter Name="Self_development" />
           <asp:Parameter Name="Technical_Development" />
           <asp:Parameter Name="Project_Management" />
           <asp:Parameter Name="Safety" />
           <asp:Parameter Name="Client_Relationship" />
           <asp:Parameter Name="Leadership_Development" />
       </InsertParameters>

        <UpdateParameters>
          <asp:Parameter Name="Self_development" />
           <asp:Parameter Name="Technical_Development" />
           <asp:Parameter Name="Project_Management" />
           <asp:Parameter Name="Safety" />
           <asp:Parameter Name="Client_Relationship" />
           <asp:Parameter Name="Leadership_Development" />
            <asp:Parameter Name="ID" />
        </UpdateParameters>
     </asp:SqlDataSource>
    </div>
    </form>
</body>
</html>

C# of Editform_csharp.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Editform_csharp : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        if (Request.QueryString["ID"] == null)
        {
            DetailsView1.DefaultMode = DetailsViewMode.Insert;
        }
        else
        {
            DetailsView1.DefaultMode = DetailsViewMode.Edit;
        }
        this.Page.Title = "ID";
    }

    protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e)
    {
        if (e.CommandName == "Update")
        {
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true);
        }
        else if (e.CommandName == "Insert")
        {
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey","CloseAndRebind('navigateToInserted');", true);
        }
        else
        {
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CancelEdit();", true);
        }
    }

    protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
    {
        //logic to truncate long string to prevent SQL error
        for (int i = 1; i < 4; i++)
        {
            string val = e.NewValues[i - 1].ToString();
            int maxLength = i * 10;
            if (val.Length > maxLength) e.NewValues[i - 1] = val.Substring(0, maxLength);
        }
    }

    protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
    {

    }
}
Eyup
Telerik team
 answered on 24 Jul 2015
1 answer
141 views

Hi Team,

Can we display dynamic fields in the UI layout? Can you help us how to achieve it.

Like initially I have 3 field naming First Name, Last Name, Mobile Number to enter, I would like to inset another  filed i.e Email Id. Can it be done? How to achieve it.

 

Thanks,

M Harika.

Eyup
Telerik team
 answered on 24 Jul 2015
6 answers
786 views
hi,

I have raddropdowntree , it works well ,
it has a checkbox  to check all nodes ,

what i  want is to know if this checkbox is checked or not (if all nodes are checked) from itemCommand event from server side ..

how to achieve that ,
HoHo
Top achievements
Rank 1
 answered on 23 Jul 2015
1 answer
109 views

I am able to put grid into edit mode by using one of the following code snippets. However, i need to edit only some of columns and leave others non editable.

How can i achieve that?

 Thank you

 

For Each item As GridItem In grdContingentDevelopment.MasterTableView.Items
            If item.GetType().ToString() = "Telerik.Web.UI.GridDataItem" Then
                Dim editableItem As GridEditableItem = DirectCast(item, GridDataItem)
                editableItem.Edit = True
            End If
 Next

 

  For i As Integer = 0 To grdContingentDevelopment.PageSize - 1
                grdContingentDevelopment.EditIndexes.Add(i)
  Next

Pavlina
Telerik team
 answered on 23 Jul 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?