Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
175 views
Hi together,

I have a little problem, i created a Grid with a SQL Data Source. In my Grid I display two Columns, the first is "ClassName from Table tblClass" and the second is "City" from tblCity. The selects are ok. Now if i update a row with this line

UpdateCommand="UPDATE [tblClass] SET [ClassName] = @ClassName, [FK_CityID] = 2 %> WHERE [PK_ClassID] = @original_PK_ClassID"

the Name will update with the text that i put in the textbox. But i don't know how i can tell to FK_CityID = "selected dropdown value"

In my Dropdown i have the Property ListValueField="PK_City_ID", so that means i have only to replace the fix ID that i have now with the selected dropdown value. But I have no idea how I can do it.

Can someone help me please? thanks a lot

Here is my Code

<telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True" Skin="Windows7" 
            AllowAutomaticInserts="True" PageSize="10" AllowAutomaticUpdates="True" AllowPaging="True"
            AutoGenerateColumns="False" DataSourceID="SessionDataSource1" OnItemUpdated="RadGrid1_ItemUpdated"
            OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted" OnDataBound="RadGrid1_DataBound">
            <PagerStyle Mode="NextPrevAndNumeric" />
              
            <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="PK_ClassID"
                DataSourceID="SessionDataSource1" HorizontalAlign="NotSet" AutoGenerateColumns="False">
                  
                  
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
                      
<%--                    <telerik:GridBoundColumn DataField="PK_ClassID" HeaderText="ID" SortExpression="PK_ClassID"
                        UniqueName="PK_ClassID" ColumnEditorID="GridTextBoxColumnEditor1">
                    </telerik:GridBoundColumn>--%>
                      
                    <telerik:GridBoundColumn DataField="ClassName" HeaderText="Class Name" SortExpression="ClassName"
                        UniqueName="ClassName" ColumnEditorID="GridTextBoxColumnEditor2">
                    </telerik:GridBoundColumn>
                      
  
                    <telerik:GridDropDownColumn DataField="FK_CityID" DataSourceID="SqlDataSource1"
                        HeaderText="City" ListTextField="City" ListValueField="PK_CityID"
                        UniqueName="PK_CityID" ColumnEditorID="GridDropDownColumnEditor1">
                    </telerik:GridDropDownColumn>
  
  
                    <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
                </Columns>
                  
                  
                  
                <EditFormSettings ColumnNumber="2" CaptionDataField="FK_CityID" CaptionFormatString="Bearbeiten der Klasse {0}" InsertCaption="Neue Klasse">
                   <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                    <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                    <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
                        Width="100%" />
                    <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record"
                        UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                    </EditColumn>
                    <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                </EditFormSettings>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnRowDblClick="RowDblClick" />
            </ClientSettings>
        </telerik:RadGrid>
  
        <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="200px" />
        <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor2" runat="server" TextBoxStyle-Width="150px" />
        <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnEditor1" runat="server" DropDownStyle-Width="110px" />
        <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server" NumericTextBox-Width="40px" />
       
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
        <br />
  
        <asp:SqlDataSource ID="SessionDataSource1" runat="server" ConnectionString="Server=.\SQLExpress ;Database=IntraIBZ;Trusted_Connection=True;"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [tblClass]"
            DeleteCommand="DELETE FROM [tblClass] WHERE [PK_ClassID] = @original_PK_ClassID" 
            InsertCommand="INSERT INTO tblClass(ClassName, FK_CityID) VALUES (@ClassName, @FK_CityID)"
            UpdateCommand="UPDATE [tblClass] SET [ClassName] = @ClassName, [FK_CityID] = 2 %> WHERE [PK_ClassID] = @original_PK_ClassID"
            OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues">
            <DeleteParameters>
                <asp:Parameter Name="original_PK_ClassID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="ClassName" Type="String" />
                <asp:Parameter Name="FK_CityID" Type="Int32" />
                <asp:Parameter Name="original_PK_ClassID" Type="Int32" />
                <asp:Parameter Name="PK_CityID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
            </InsertParameters>
</asp:SqlDataSource>
  
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Server=.\SQLExpress ;Database=IntraIBZ;Trusted_Connection=True;"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT [PK_CityID], [City] FROM [tblCity]">
        </asp:SqlDataSource>
  
  
                <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
  
            <script type="text/javascript">
                function RowDblClick(sender, eventArgs) {
                    sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
                }
            </script>
  
        </telerik:RadCodeBlock>
Tsvetoslav
Telerik team
 answered on 02 Dec 2010
1 answer
85 views
Dear Forum,

I have a RadGrid with drag-and-drop grouping enabled and a default top level grouping set. I'm using the Q1 2010 build with VS2008 and ASP.net 3.5 C#.

I collapsed all to the top level grouping using the example from
http://www.telerik.com/help/aspnet-ajax/grdcollapseallitemsongrouping.html

What I would like to do is to collapse all groups except for the last group the client selects each time the client drags and drops a new group to the group by bar.

Does anyone have an example of this or can anyone point me in the right direction.

Thank you,
Celeste
Tsvetina
Telerik team
 answered on 02 Dec 2010
7 answers
248 views
Hi!

I've been fiddling a bit with the new TreeList control, and manage to add some template columns dynamically.
It seems it's ok to remove a few and add more, but when I remove a lot and add less, I get an exception saying


Invalid column type: "TreeListTemplateColumn".

[Exception: Invalid column type: "TreeListTemplateColumn".]
   Telerik.Web.UI.RadTreeList.CreateColumnByType(String columnType) +184
   Telerik.Web.UI.TreeListColumnsCollection.System.Web.UI.IStateManager.LoadViewState(Object state) +350
   Telerik.Web.UI.RadTreeList.LoadViewState(Object savedState) +97
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +183
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
   System.Web.UI.Page.LoadAllState() +312
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1661

This also happens when "a lot" of columns has been added and I try to collapse a section.

I guess it's pretty easy to reproduce if you just fiddle a bit with the following page / code.
Try for instance to expand "A", then click "Month", and try to collapse "A".
Or just click "Month" then "Quarter".

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TreeViewTimeline.aspx.cs"
    Inherits="Web20.TreeViewTimelineTelerik.TreeViewTimeline" EnableEventValidation="false" %>
  
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <asp:LinkButton ID="QtrButton" runat="server" Text="Quarter" OnClick="QtrButtonClicked" />
        <asp:LinkButton ID="MonthButton" runat="server" Text="Month" OnClick="MonthButtonClicked" />
      
        <div id="tbl-container">
            <telerik:RadTreeList runat="server" ID="treeList" Skin="Vista" AutoGenerateColumns="False"
                OnInit="treeListInit"
                DataKeyNames="ID" ParentDataKeyNames="Parent" OnItemCommand="treeListItemCommand"
                  
                >
                <Columns>
                    <telerik:TreeListTemplateColumn UniqueName="Name" HeaderText="Navn" >
                        <HeaderStyle />
                        <ItemStyle />
                        <ItemTemplate>
                            <asp:TextBox runat="server" ID="NameTextBox" Text='<%# Eval("Name") %>' />
                        </ItemTemplate>
                    </telerik:TreeListTemplateColumn>
                </Columns>
            </telerik:RadTreeList>
        </div>
    </div>
    </form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
  
namespace Web20.TreeViewTimelineTelerik
{
    public partial class TreeViewTimeline : System.Web.UI.Page
    {
        public string Mode
        {
            get { return ViewState["mode"] as string ?? "Quarter"; }
            set { ViewState["mode"] = value; }
        }
  
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindList();
            }
        }
  
        private void BindList() 
        {
            var list = new[]
                       {
                        new Item {ID = "A", Name = "A", Parent = "", Periods = new Dictionary<string, Period>
                              {{"Q1", new Period {Name = "Q1"}}, {"Feb", new Period {Name="1/10"}}}}
                        , new Item {ID = "B", Name = "B", Parent = ""}
                        , new Item {ID = "A.A", Name = "A.A", Parent = "A", Periods = new Dictionary<string, Period> 
                              {{"Q2", new Period { Name = "Qtr 2"}}, {"Q3", new Period {Name="Qty 3"}}, {"Mar", new Period{Name="2/10"}} }}
                       };
  
            treeList.DataSource = list;
            treeList.DataBind();
        }
  
        protected void treeListItemCommand(object sender, TreeListCommandEventArgs e)
        {
            if (e.CommandName == RadTreeList.ExpandCollapseCommandName)
            {
                ResetColumns();
            }
        }
  
        protected void treeListInit(object sender, EventArgs e)
        {
            InitColumns();
        }
  
        private void InitColumns()
        {
            switch(Mode)
            {
                case "Quarter":
                    string[] quarters = new[] {"Q1", "Q2", "Q3", "Q4"};
                    foreach(string quarter in quarters)
                        treeList.Columns.Add(new TreeListTemplateColumn{UniqueName = quarter, HeaderText = quarter, ItemTemplate = new PeriodTemplate(quarter)});
                    break;
                case "Month":
                    string[] months = new[] {"Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des"};
                    foreach(string month in months)
                        treeList.Columns.Add(new TreeListTemplateColumn { UniqueName = month, HeaderText = month, ItemTemplate = new PeriodTemplate(month) });
                    break;
            }
        }
  
        private void ResetColumns() {
            RemoveDynamicColumns();
            InitColumns();
            BindList();
        }
  
        private void RemoveDynamicColumns()
        {
            for(int i = treeList.Columns.Count - 1; i>=1; i--)
                treeList.Columns.RemoveAt(i);
        }
  
        protected void QtrButtonClicked(object sender, EventArgs e)
        {
            Mode = "Quarter";
            ResetColumns();
        }
  
        protected void MonthButtonClicked(object sender, EventArgs e)
        {
            Mode = "Month";
            ResetColumns();
        }
    }
  
    public class PeriodTemplate : ITemplate
    {
        private readonly string quarter;
  
        public PeriodTemplate(string quarter)
        {
            this.quarter = quarter;
        }
  
        public void InstantiateIn(Control container)
        {
            Label label = new Label();
            label.EnableViewState = false;
            label.ID = quarter + "Label";
            Item dataItem = (Item)DataBinder.GetDataItem(container.BindingContainer);
            if (dataItem != null && dataItem.Periods != null)
            {
                if (dataItem.Periods.ContainsKey(quarter))
                    label.Text = dataItem.Periods[quarter].Name;
            }
            container.Controls.Add(label);
        }
    }
  
    public class Item
    {
        public string ID { get; set; }
        public string Parent { get; set; }
        public string Name { get; set; }
  
        public Dictionary<string, Period> Periods { get; set; }
    }
  
    public class Period
    {
        public string Name { get; set; }
    }
}

Hope you guys can help. :)

Lars-Erik

Lars-Erik
Top achievements
Rank 1
 answered on 02 Dec 2010
2 answers
106 views
Hi,

I upgrade my os WinXP to  Win7 64 bit but when debug my web application gives some javascript errors. For example; I have to put my web page below this code for RadComboBox;
Telerik.Web.UI.RadComboBox.prototype._removeDropDown = function() {
            var slide = this.get_dropDownElement().parentNode;
            slide.parentNode.removeChild(slide);
  
            if (this._disposeChildElements)
                $telerik.disposeElement(slide);
  
            if (!$telerik.isSafari)
                slide.outerHTML = null;
            this._dropDownElement = null;
        };

But this code block is not run on RadTabstrip. When I click another tab which has no RadCombobox that gives an error. Also I get javascript errors in  some pages redirecting. How to avoid this errors ?
YAVUZ
Top achievements
Rank 1
 answered on 02 Dec 2010
3 answers
146 views
Hi there,

I have an ASP.net wizard control, with a RadDatePicker on one of the steps. I have added a RequiredFieldValidator as per this documentation. 

Unfortunately, the validator isn't firing when I enter an invalid date, and I can move to the next step in the wizard. If I move to the next step, then return to the previous step and enter an invalid date, it then fires.

My code for the RadDatePicker and Validator is as below:
<telerik:RadDatePicker ID="rdpMAEDROut" Runat="server" Culture="en-US">
    <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False"
            ViewSelectorText="x" daynameformat="Short" showrowheaders="False"></Calendar>
    <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
    <DateInput DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy"
            emptymessage="dd/mm/yyyy" CssClass="RDPInvalid"></DateInput>
</telerik:RadDatePicker>
<asp:RequiredFieldValidator CssClass="RequiredFieldValidator"
        ID="rfvMAEDROut" runat="server"
     ControlToValidate="rdpMAEDROut"
        ErrorMessage="You must enter a valid value in this field." ></asp:RequiredFieldValidator>

Any ideas would be greatly appreciated :)

Maria Ilieva
Telerik team
 answered on 02 Dec 2010
3 answers
84 views
Hi,
i am using RadMaskedTextBox,i am facing one issue ,please follow the following example.

I have set mask as Letter

i have entered "abc" first time

next time i put mouse point  at before  "a" letter  and trying enter letters "def",actually my Intention is enter total text as "defabc",but it is overlapping abc and enters "def"

please let me know is there any way to solve this issue,


Maria Ilieva
Telerik team
 answered on 02 Dec 2010
3 answers
105 views
Hi,

I have a page with a lot of Rad Controls on it - inside a RadGrid control. I have a RadAjaxManager on the page master page and I am using Rad Ajax Manager Proxy on each page. Also I am intensively using the client-side API of the RadControls (RadComboBox, RadNumericBox, etc). The grid control is inside a RadPageView and I am usign RadTabStrip to switch between different other views.
All of this is AJAX-enabled (I have turned the  RenderSelectedPageOnly = true of the Radmultipage, however, if set to false does not make a difference). The problem is that each time I switch to another tab and then return to the previous (with the grid and the controls), or when I perform sorting of the grid, the clientside objects for the editor controls (I use $find('controlClientID')) , it is null.
Any clues on this issue will be helpful.
Maria Ilieva
Telerik team
 answered on 02 Dec 2010
5 answers
147 views
Hi! I require all of my RadGrids using the below Skin to ge exportable without paging. Issue is that all grids are on Content Pages that inherit a Single Master page with a RadAjaxManager. All child pages have a RadAjaxManagerProxy. So all grids are AJAXified. I'm into completion here so a major overhaul is not optional. kindly advice a strategy. All grids have different names, btw.

Thanks.

<telerik:RadGrid runat="server" GridLines="None" Skin="Office2007" SkinID="RadGrid_UnPageable" >   
    <MasterTableView EnableNoRecordsTemplate="true" ShowHeadersWhenNoRecords="true">
      <CommandItemSettings ShowRefreshButton="true" ShowExportToWordButton="false" ShowExportToExcelButton="false" ShowExportToPdfButton="false" ShowExportToCsvButton="false" />
        <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" Position="Bottom" />
        <NoRecordsTemplate>There is no data to display.</NoRecordsTemplate>
    </MasterTableView>
    <ExportSettings HideStructureColumns="true" ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" />
    <ClientSettings>
        <Selecting AllowRowSelect="True" />
    </ClientSettings>
</telerik:RadGrid>
Daniel
Telerik team
 answered on 02 Dec 2010
5 answers
156 views
Hi,

I´d like to get return of RadConfirm when Button NO was pressed.
How can I do that at runtime with VB.net?

Tks

Luiz
Georgi Tunev
Telerik team
 answered on 02 Dec 2010
3 answers
159 views
Hi,
Is any property in TreeView to set max width of node?
In my application some nodes are too long:
http://img232.imageshack.us/img232/5127/telerik.png
How to fix this?

Thanks.
Dimitar Terziev
Telerik team
 answered on 02 Dec 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
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?