Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
109 views
When i move more docks, after the 3rd dock i get an error 500.

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.Data.SqlClient;
using System.Text;
using System.Collections;
using System.Configuration;
 
 
public partial class mods_arrange : System.Web.UI.UserControl
{
    private int _userID = 1;
    private SqlConnection _conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
    private List<DockState> CurrentDockStates
    {
        get
        {
            //Get saved state string from the database - set it to dockState variable for example
            string dockStatesFromDB = "";
            if (Request.Cookies["landingStates_V"] != null)
            {
                dockStatesFromDB = Request.Cookies["landingStates_V"].Value;
            }
            else
            {
                _conn.Open();
                SqlCommand command = new SqlCommand("select State from landing_States where id='" + _userID + "' ", _conn);
                dockStatesFromDB = command.ExecuteScalar().ToString();
                _conn.Close();
            }
            List<DockState> _currentDockStates = new List<DockState>();
            string[] stringStates = dockStatesFromDB.Split('|');
            foreach (string stringState in stringStates)
            {
                if (stringState.Trim() != string.Empty)
                {
                    _currentDockStates.Add(DockState.Deserialize(stringState));
                }
            }
            return _currentDockStates;
        }
    }
 
    protected void Page_Load(object sender, EventArgs e)
    {
        //RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
        //manager.ClientEvents.OnRequestStart = "RequestStart";
        //manager.ClientEvents.OnResponseEnd = "ResponseEnd";
 
        if (!IsPostBack)
        {
            DropDownZone.DataBind();
 
        }
    }
 
    public ArrayList GetZones()
    {
        ArrayList zones = new ArrayList();
        zones.Add(RadDockZone1);
        zones.Add(RadDockZone2);
        zones.Add(RadDockZone3);
        return zones;
    }
 
    protected void Page_Init(object sender, EventArgs e)
    {
 
        //Recreate the docks in order to ensure their proper operation
        for (int i = 0; i < CurrentDockStates.Count; i++)
        {
            if (CurrentDockStates[i].Closed == false)
            {
                RadDock dock = CreateRadDockFromState(CurrentDockStates[i]);
 
                //We will just add the RadDock control to the RadDockLayout.
                // You could use any other control for that purpose, just ensure
                // that it is inside the RadDockLayout control.
                // The RadDockLayout control will automatically move the RadDock
                // controls to their corresponding zone in the LoadDockLayout
                // event (see below).
                RadDockLayout1.Controls.Add(dock);
 
                //We want to save the dock state every time a dock is moved.
                CreateSaveStateTrigger(dock);
                //Load the selected widget
                LoadWidget(dock);
 
            }
        }
        loadCheckboxes();
    }
    private void loadCheckboxes()
    {
        ListItem i1 = new ListItem("News", "~/Controls/News.ascx");
        ListItem i2 = new ListItem("Events", "~/Controls/Events.ascx");
        ListItem i3 = new ListItem("Languages", "~/Controls/Languages.ascx");
        ListItem i4 = new ListItem("Market", "~/Controls/MarketIndex.ascx");
        ListItem i5 = new ListItem("VC", "~/Controls/VC.ascx");
        ListItem i6 = new ListItem("DVD", "~/Controls/DVD.ascx");
        ListItem i7 = new ListItem("PIF", "~/Controls/PIF.ascx");
        CheckBoxList1.Items.Add(i1);
        CheckBoxList1.Items.Add(i2);
        CheckBoxList1.Items.Add(i3);
        CheckBoxList1.Items.Add(i4);
        CheckBoxList1.Items.Add(i5);
        CheckBoxList1.Items.Add(i6);
        CheckBoxList1.Items.Add(i6);
 
        LcookieCheck();
    }
 
    protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)
    {
        //Populate the event args with the state information. The RadDockLayout control
        // will automatically move the docks according that information.
        //if (!IsPostBack)
        //{
        //    foreach (DockState state in CurrentDockStates)
        //    {
        //        e.Positions[state.UniqueName] = state.DockZoneID;
        //        e.Indices[state.UniqueName] = state.Index;
        //    }
        //}
        if (!Page.IsPostBack)
        {
            string dockStatesFromCookie = "";
 
            HttpCookie cookieStates = Request.Cookies["dockState"];
 
            if (cookieStates != null)
            {
                dockStatesFromCookie = cookieStates.Value;
                string[] stringStates = dockStatesFromCookie.Split('|');
 
                Hashtable states = new Hashtable();
                for (int i = 0; i < stringStates.Length - 1; i++)
                {
                    string[] currentState = stringStates[i].Split('#');
                    string uniqueName = currentState[0];
                    string state = currentState[1];
                    states.Add(uniqueName, state);
                }
 
                foreach (RadDock dock in RadDockLayout1.RegisteredDocks)
                {
                    string uniqueName = dock.UniqueName;
                    DockState state = DockState.Deserialize(states[uniqueName].ToString());
                    dock.ApplyState(state);
                }
            }
        }
    }
 
    protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)
    {
        List<DockState> stateList = RadDockLayout1.GetRegisteredDocksState();
        StringBuilder serializedList = new StringBuilder();
        int i = 0;
 
        while (i < stateList.Count)
        {
            serializedList.Append(stateList[i].ToString());
            serializedList.Append("|");
            i++;
        }
 
        string dockState = serializedList.ToString();
        if (dockState.Trim() != String.Empty)
        {
            if (Request.Cookies["landingStates_V"] != null)
            {
                Response.Cookies["landingStates_V"].Value = dockState;
            }
            else
            {
                Response.Cookies["landingStates_V"].Value = dockState;
                Response.Cookies["landingStates_V"].Expires = DateTime.Now.AddDays(5);
            }
            _conn.Open();
            //SqlCommand command = new SqlCommand(String.Format("update landing_States set State='{0}' where id='" + _userID + "'", dockState), _conn);
            //command.ExecuteNonQuery();  //update Dbase
            _conn.Close();
        }
 
    }
 
    private RadDock CreateRadDockFromState(DockState state)
    {
        RadDock dock = new RadDock();
        dock.DockMode = DockMode.Docked;
        dock.ID = string.Format("RadDock{0}", state.UniqueName);
        dock.ApplyState(state);
        //by aresh
        dock.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.None;
        dock.DockMode = DockMode.Docked;
        dock.CssClass = "vbox" + state.Title.Replace(' ', 'a');
 
        DockToggleCommand cmd = new DockToggleCommand();
        cmd.OnClientCommand = "OnClientCommand" + state.Title.Replace(' ', 'a');
        cmd.Text = "Edit";
        cmd.CssClass = "rdEdit";
        cmd.AutoPostBack = false;
 
 
        DockCloseCommand cmdclose = new DockCloseCommand();
        cmdclose.AutoPostBack = false;//true;
 
        DockExpandCollapseCommand cmdminmax = new DockExpandCollapseCommand();
        cmdminmax.AutoPostBack = false;
 
 
        dock.Commands.Add(cmdclose);
        dock.Commands.Add(cmdminmax);
        //dock.Commands.Add(cmd);
 
        return dock;
    }
    private RadDock CreateRadDock(String name)
    {
        int docksCount = CurrentDockStates.Count;
 
        RadDock dock = new RadDock();
        dock.DockMode = DockMode.Docked;
        dock.UniqueName = Guid.NewGuid().ToString().Replace(' ', 'a');
        dock.ID = string.Format("RadDock{0}", dock.UniqueName);
        dock.Title = name.Replace('_', ' ');
        dock.Width = Unit.Pixel(300);
        //by aresh
        dock.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.None;
        dock.DockMode = DockMode.Docked;
        dock.CssClass = "vbox" + name.Replace(' ', 'a');
 
        DockToggleCommand cmd = new DockToggleCommand();
        cmd.OnClientCommand = "OnClientCommand" + name.Replace(' ', 'a'); ;
        cmd.Text = "Edit";
        cmd.CssClass = "rdEdit";
        cmd.AutoPostBack = false;
 
 
        DockCloseCommand cmdclose = new DockCloseCommand();
        cmdclose.AutoPostBack = false;//true;
 
        DockExpandCollapseCommand cmdminmax = new DockExpandCollapseCommand();
        cmdminmax.AutoPostBack = false;
 
 
        dock.Commands.Add(cmdclose);
        dock.Commands.Add(cmdminmax);
        //dock.Commands.Add(cmd);
 
        return dock;
    }
    private void CreateSaveStateTrigger(RadDock dock)
    {
        //Ensure that the RadDock control will initiate postback
        // when its position changes on the client or any of the commands is clicked.
        //Using the trigger we will "ajaxify" that postback.
        dock.AutoPostBack = true;
        dock.CommandsAutoPostBack = false;
 
        AjaxUpdatedControl updatedControl = new AjaxUpdatedControl();
        updatedControl.ControlID = "Panel1";
 
        AjaxSetting setting1 = new AjaxSetting(dock.ID);
        setting1.EventName = "DockPositionChanged";
        setting1.UpdatedControls.Add(updatedControl);
 
        RadAjaxManagerArrange.AjaxSettings.Add(setting1);
    }
    private void LoadWidget(RadDock dock)
    {
        if (string.IsNullOrEmpty(dock.Tag))
        {
            return;
        }
        Control widget = LoadControl(dock.Tag);
        dock.ContentContainer.Controls.Add(widget);
    }
 
 
    protected void ButtonAddDock_Click(object sender, EventArgs e)
    {
        //Load the selected widget in the RadDock control
        foreach (ListItem con in CheckBoxList1.Items)
        {
            if (con.Selected == true)
            {
                WcookieCheck(con.Value, con.Text);
                RadDock dock = CreateRadDock(con.Text);
                //find the target zone and add the new dock there
                RadDockZone dz = (RadDockZone)FindControl(DropDownZone.SelectedItem.Text);
                dz.Controls.Add(dock);
 
                CreateSaveStateTrigger(dock);
 
                dock.Tag = con.Value;
                LoadWidget(dock);
 
                //Register a script to move dock to the last place in the RadDockZone
                //The zone.dock(dock,index) client-side method is used
                ScriptManager.RegisterStartupScript(this,
                    this.GetType(),
                    "MoveDock",
                string.Format(@"function _moveDock() {{
                            Sys.Application.remove_load(_moveDock);
                            $find('{1}').dock($find('{0}'),{2});
                            }};
                            Sys.Application.add_load(_moveDock);", dock.ClientID, DropDownZone.SelectedValue, dz.Docks.Count),
                true);
            }
        }Response.Redirect("/default.aspx");
 
    }
    protected void ButtonPostBack_Click(object sender, EventArgs e)
    {
        if (Request.Cookies["landingChecks_V"] != null)
        {
            HttpCookie myCookie = new HttpCookie("landingChecks_V");
            myCookie.Expires = DateTime.Now.AddDays(-1d);
            Response.Cookies.Add(myCookie);
        }
        Response.Redirect("default.aspx");
    }
 
 
    private void WcookieCheck(string val, string txt)
    {
        HttpCookie cookie = Request.Cookies["landingChecks_V"];
        if (cookie != null)
        {
            cookie.Expires = DateTime.Now.AddYears(-30);
            Response.Cookies.Remove("landingChecks_V");
 
            HttpCookie Newcookie = new HttpCookie("landingChecks_V");
            Newcookie.Expires = DateTime.Now.AddDays(5);
            Newcookie.Values.Add(val, txt);
            Response.Cookies.Add(Newcookie);
 
            cookie.Values.Add(val, txt);
            Response.Cookies.Add(cookie);
        }
        else
        {
            HttpCookie Newcookie = new HttpCookie("landingChecks_V");
            Newcookie.Expires = DateTime.Now.AddDays(5);
            Newcookie.Values.Add(val, txt);
            Response.Cookies.Add(Newcookie);
 
        }
    }
    private void LcookieCheck()
    {
        HttpCookie cookie = Request.Cookies["landingChecks_V"];
        if (cookie != null && cookie.Values != null)
        {
            foreach (string key in cookie.Values.Keys)
            {
                ListItem item = CheckBoxList1.Items.FindByValue(key);
                if (item != null)
                {
                    item.Selected = true;
                }
            }
        }
        else
        {
            CheckBoxList1.Items[0].Selected = true;
            CheckBoxList1.Items[1].Selected = true;
            CheckBoxList1.Items[2].Selected = true;
            CheckBoxList1.Items[3].Selected = true;
            CheckBoxList1.Items[4].Selected = true;
            CheckBoxList1.Items[5].Selected = true;
            CheckBoxList1.Items[6].Selected = true;
        }
 
    }
}

how do i load the docks from the cookie state using the checkboxes?

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="arrange.ascx.cs" Inherits="mods_arrange" %>
 
<div class="content-in">
     
 <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
 
        <script type="text/javascript">
            var currentLoadingPanel = null;
            var currentUpdatedControl = null;
            function RequestStart(sender, args) {
                currentLoadingPanel = $find("<%= LoadingPanel1.ClientID %>");
                currentUpdatedControl = "TableLayout";
                currentLoadingPanel.show(currentUpdatedControl);
            }
            function ResponseEnd() {
                //hide the loading panel and clean up the global variables
                if (currentLoadingPanel != null)
                    currentLoadingPanel.hide(currentUpdatedControl);
                currentUpdatedControl = null;
                currentLoadingPanel = null;
            }
        </script>
 
    </telerik:RadCodeBlock>
     
 
    <br />
    <asp:Panel ID="Panel1" runat="server">
        <telerik:RadDockLayout runat="server" ID="RadDockLayout1"  OnSaveDockLayout="RadDockLayout1_SaveDockLayout"
            OnLoadDockLayout="RadDockLayout1_LoadDockLayout" EnableEmbeddedSkins="false" Skin="myx" EnableViewState="false">
            <table id="TableLayout" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td>
            <div class="left">
                        <telerik:RadDockZone runat="server" ID="RadDockZone1"  >
                        </telerik:RadDockZone>
            </div>
            <div class="center">
                        <telerik:RadDockZone runat="server" ID="RadDockZone2"  >
                        </telerik:RadDockZone>
            </div>
            <div class="right">
                        <telerik:RadDockZone runat="server" ID="RadDockZone3" >
                        </telerik:RadDockZone>
            </div>
                    </td>
                </tr>
            </table>
        </telerik:RadDockLayout>
    </asp:Panel>
 
<asp:Panel ID="Panel2" runat="server" CssClass="customizePanel">
    <a name="customizepage"></a>
    <div class="movable">
    <div class="draggable"><h2>Customize</h2></div>
    <div class="block">
 
 
 
    <div>
        <p>
        <%= vboxTitles.getTitle("Add and remove your preferred topics", Request.QueryString["language"])%>
</p>
<asp:CheckBoxList ID="CheckBoxList1" runat="server"  Enabled="false"
RepeatLayout="UnorderedList">
</asp:CheckBoxList>
                          
<asp:DropDownList ID="DropDownZone" runat="server" DataSource="<%#GetZones() %>"
DataTextField="ID" DataValueField="ClientID" Width="150" Visible="false" >
</asp:DropDownList>
<br />
<br />
<telerik:RadButton ID="ButtonAddDock" runat="server"  OnClick="ButtonAddDock_Click"
                    Text="Save">
                        <Icon PrimaryIconCssClass="rbOk" PrimaryIconLeft="4" PrimaryIconTop="4" />
                </telerik:RadButton>
<asp:Button runat="server" CssClass="button" ID="ButtonPostBack" Text="Reset"
OnClick="ButtonPostBack_Click" />
    <div class="clear"></div>
    </div>
 
 
    </div>
    <div class="block-bottoml">
    <div class="block-bottomr"></div>
    </div>
    </div>
</asp:Panel>
                 
                         
        <br />
    </div>   
 
<telerik:RadAjaxManager  ID="RadAjaxManagerArrange" runat="server" ClientEvents-OnRequestStart="RequestStart"
        ClientEvents-OnResponseEnd="ResponseEnd">
<AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="ButtonAddDocks" EventName="Click">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Panel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
</telerik:RadAjaxManager>
 
    <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" MinDisplayTime="500"
        Skin="Default">
    </telerik:RadAjaxLoadingPanel>
 
please help with sample project on how to get this working

thank you
Slav
Telerik team
 answered on 24 Jun 2011
1 answer
58 views
I am using client-side binding for my grid. When i have 50 records per page - which is not much - i get 1 "Stop running this script" messagebox in IE8. If number of records per page is more - it's customizable - i get event more such messageboxes.

The point is that execution time is not so long! Messagebox appears, even though user could wait this time without any problem!

In Mozilla everything is ok.

I have found that the problem is exactly filling the grid. When I comment the line
tableView.dataBind()

the page is shown without any javascript timeouts (but of course, with empty grid :) )

What could be done to get rid of this error?



Tsvetoslav
Telerik team
 answered on 24 Jun 2011
1 answer
139 views
Hello there,

I am using the radGrid and am updating values using edit forms.
 On the code behind I couldn't get the updated values that i entered in the text-boxes. It always shows the old values. I have tried two approaches. using the ExtractValuesFromItem(dictonaryObject, editedItem) method and Fetching the data from each edited field individually through the auto-generated column editors, which both seems not to work. here is the markup for the grid and the code behind.
I would appreciate if somebody can help me out with this issue. I only have a day.

 



<
tlrk:RadGrid ID="tlrkExpGrid" runat="server" CellSpacing="0" 

GridLines="None" AutoGenerateColumns = "False"  

OnUpdateCommand = "expDG_RowUpdating" >

 <MasterTableView commanditemdisplay="Top" EditMode = "EditForms" DataKeyNames = "ex_code">

 <Columns>
<tlrk:GridEditCommandColumn ButtonType="LinkButton" UniqueName="EditCommandColumn">

 <ItemStyle CssClass="MyImageButton"/>

 </tlrk:GridEditCommandColumn>

 <tlrk:GridBoundColumn DataField="ex_code" HeaderText="Code"  UniqueName="ex_code" >

 </tlrk:GridBoundColumn>

 <tlrk:GridBoundColumn DataField="ex_name" HeaderText="Name" UniqueName="ex_name" >

 </tlrk:GridBoundColumn>

 <tlrk:GridBoundColumn DataField="DUNS" HeaderText="DUNS" UniqueName="DUNS" >

 </tlrk:GridBoundColumn>

 <tlrk:GridBoundColumn DataField="email" HeaderText="Email" UniqueName="email" ColumnEditorID = "emailEditor">

 </tlrk:GridBoundColumn>

 <tlrk:GridButtonColumn ConfirmText="Delete this Exporter?" ConfirmDialogType="RadWindow"

 ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"

 UniqueName="DeleteColumn">

 <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />

</tlrk:GridButtonColumn>

 </Columns>

 <EditFormSettings>

 <EditColumn UniqueName="EditCommandColumn" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>

 </EditFormSettings>

  </MasterTableView>

 </tlrk:RadGrid>

 
protected

void expDG_RowUpdating(object source,Telerik.Web.UI.GridCommandEventArgs e)

 {

 GridEditableItem editedItem = e.Item as GridEditableItem;

 string expCode = (editedItem["ex_code"].Controls[0] as TextBox).Text;

 string expName = (editedItem["ex_name"].Controls[0] as TextBox).Text;

 string duns = (editedItem["DUNS"].Controls[0] as TextBox).Text;

string email = (editedItem["email"].Controls[0] as TextBox).Text;

//this is the first approach

 Hashtable newValues = new Hashtable();

 e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);

 

//this was the second approach trying to loop through each editor 

GridTextBoxColumnEditor editor = (GridTextBoxColumnEditor)editedItem.EditManager.GetColumnEditor("email");

TextBox t = editor.TextBoxControl;

string ee = t.Text;

GridEditableItem editedItem = e.Item as GridEditableItem;

 GridEditManager editMan = editedItem.EditManager;

  

 

 foreach( GridColumn column in e.Item.OwnerTableView.RenderColumns )

 {

 if ( column is IGridEditableColumn )

 {

  IGridEditableColumn editableCol = (column as IGridEditableColumn);

  if ( editableCol.IsEditable )

 {

  IGridColumnEditor editor = editMan.GetColumnEditor( editableCol );

  string editorType = editor.ToString();

  string editorText = "unknown";

  object editorValue = null;

 if ( editor is GridTextColumnEditor )

 {

 editorText = (editor as GridTextColumnEditor).Text;

 editorValue = (editor as GridTextColumnEditor).Text;

  }

}

}

}

 

Iana Tsolova
Telerik team
 answered on 24 Jun 2011
11 answers
122 views

I have RadChart with 30 items on X scale. They all have values 0, and I am not showing it (visible=false). I am doing it because I would like to show empty char, but with correct scale (if you don't add any items, there will be red label in center with text about missing data).

So far, so good. But the problem is the chart Y scale goes by default from -50 to +50. And now is my question -- how do you change it, to go from 0, to default (50 is fine)?

I added in ascx file the tags

<PlotArea>

<YAxis2 MinValue=0></YAxis2>
<YAxis MinValue=0></YAxis>

</PlotArea>

It does not work. So I added the equivalent of this in C# code, just after adding data. Still, no change. So how do you set this min value for Y scale?

eugen100
Top achievements
Rank 1
 answered on 24 Jun 2011
1 answer
201 views
I have a grid that was working fine, but I wanted to add a detail table to it.  When I did, it stopped working.  It's saying that it can't find a column that I am 100% sure exists.  I'm using an ObjectDataSource that returns an IList to bind the detail table with.  Is there something I'm missing?

<%@ Page Title="" Language="C#" MasterPageFile="~/AppMasterPage.master" AutoEventWireup="true" CodeFile="Research.aspx.cs" Inherits="MoneyOrder_Research" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
    <center>
        <table>
            <tr>
                <td style="color:Blue;font-size:large"><strong>Money Order Research</strong><br /></td>
            </tr>
            <tr>
                <td><asp:Label ID="errorLabel" runat="server" Font-Bold="True" Font-Size="Large"
                        Font-Underline="True" ForeColor="#990000"></asp:Label><br /></td>
            </tr>
        </table>
    </center>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">       
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="moGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="moGrid" LoadingPanelID="RadAjaxLoadingPanel1" />                       
                </UpdatedControls>
            </telerik:AjaxSetting>             
        </AjaxSettings>       
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="WebBlue" />   
    <telerik:RadGrid ID="moGrid" runat="server" OnNeedDataSource="moGrid_NeedDataSource" ShowStatusBar="true" AllowFilteringByColumn="true" ShowFooter="true"
            AutoGenerateColumns="False" PageSize="15" AllowSorting="True" AllowPaging="True" GridLines="Vertical" ShowHeader="true" ShowGroupPanel="true"
            Skin="WebBlue" AlternatingItemStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
            FilterItemStyle-HorizontalAlign="Center" GroupingSettings-CaseSensitive="false">
        <ClientSettings AllowDragToGroup="True">       
        </ClientSettings>        
        <MasterTableView DataKeyNames="ID,Location" HierarchyLoadMode="Client">             
            <DetailTables>           
                <telerik:GridTableView Name="histTable" DataKeyNames="ID,Location,MOID,MOLoc" DataSourceID="histSource" AutoGenerateColumns="true">
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="MOID" MasterKeyField="ID" />
                        <telerik:GridRelationFields DetailKeyField="MOLoc" MasterKeyField="Location" />
                    </ParentTableRelation>                   
                </telerik:GridTableView>
            </DetailTables
        <SortExpressions>
            <telerik:GridSortExpression FieldName="DateAdd" SortOrder="Descending" />
        </SortExpressions>
            <Columns>
                <telerik:GridBoundColumn SortExpression="ID" HeaderText="ID" HeaderButtonType="TextButton" FilterDelay="8000" CurrentFilterFunction="EqualTo" Aggregate="Count"
                    DataField="ID" UniqueName="MO_ID" AutoPostBackOnFilter="false" ShowFilterIcon="false" AllowFiltering="true"></telerik:GridBoundColumn>                                           
                <telerik:GridTemplateColumn SortExpression="Location" HeaderText="Location" HeaderButtonType="TextButton" FilterDelay="8000" CurrentFilterFunction="EqualTo"
                    DataField="Location" UniqueName="MO_Location" GroupByExpression="Location Group By Location"  AutoPostBackOnFilter="false" ShowFilterIcon="false" AllowFiltering="true">
                    <ItemTemplate>
                        <asp:Label ID="MOLocationLbl" runat="server" Text='<%# Eval("Location") %>'></asp:Label>
                    </ItemTemplate>
                    <FilterTemplate>
                        <telerik:RadComboBox ID="locBox" runat="server" DataSourceID="locationSource" AppendDataBoundItems="true" Width="90px"
                            SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("MO_Location").CurrentFilterValue %>'
                            OnClientSelectedIndexChanged="SelectedLocIndexChanged" >
                            <Items>
                                <telerik:RadComboBoxItem runat="server" Text="All Locations" Value="" />
                            </Items>
                        </telerik:RadComboBox>
                        <telerik:RadScriptBlock ID="locFilterScript" runat="server">
                            <script type="text/javascript">
                                function SelectedLocIndexChanged(sendrer, args) {
                                    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                    tableView.filter("MO_Location", args.get_item().get_value(), "EqualTo");
                                }
                            </script>                               
                        </telerik:RadScriptBlock>
                    </FilterTemplate>
                </telerik:GridTemplateColumn>                                           
                <telerik:GridBoundColumn SortExpression="ACROrder" HeaderText="Order #" HeaderButtonType="TextButton" FilterDelay="8000" CurrentFilterFunction="EqualTo"
                    DataField="ACROrder" UniqueName="MO_ACROrder" AutoPostBackOnFilter="false" ShowFilterIcon="false" AllowFiltering="true"></telerik:GridBoundColumn>                                                           
                <telerik:GridBoundColumn SortExpression="Amount" HeaderText="Amount" HeaderButtonType="TextButton" FilterDelay="8000" DataField="Amount" Aggregate="Sum"
                    UniqueName="MO_Amount" AutoPostBackOnFilter="false" ShowFilterIcon="true" AllowFiltering="true" DataFormatString="{0:C}"></telerik:GridBoundColumn>                                                                           
                <telerik:GridTemplateColumn SortExpression="Status" HeaderText="Status" GroupByExpression="Status Group By Status" HeaderButtonType="TextButton" FilterDelay="8000" CurrentFilterFunction="EqualTo"
                    DataField="Status" UniqueName="MO_Status" AutoPostBackOnFilter="false" ShowFilterIcon="false" AllowFiltering="true">
                    <ItemTemplate>
                        <asp:Label ID="MOStatusLabel" runat="server" Text='<%# Eval("StatusText") %>'></asp:Label>
                    </ItemTemplate>
                    <FilterTemplate>
                        <telerik:RadComboBox ID="statusFilter" runat="server" DataSourceID="statusSource" DataTextField="Text" DataValueField="Value" Width="90px"
                            AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("MO_Status").CurrentFilterValue %>'
                            OnClientSelectedIndexChanged="SelectedStatusIndexChanged">
                            <Items>
                                <telerik:RadComboBoxItem runat="server" Text="All Statuses" Value="" />
                            </Items>
                        </telerik:RadComboBox>
                        <telerik:RadScriptBlock ID="filterStatusScriptBlock" runat="server">
                            <script type="text/javascript">
                                function SelectedStatusIndexChanged(sender, args) {
                                    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                    tableView.filter("MO_Status", args.get_item().get_value(), "EqualTo");
                                }
                            </script>
                        </telerik:RadScriptBlock>
                    </FilterTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn SortExpression="SuspActivityFlag" GroupByExpression="SuspActivityFlag Group By SuspActivityFlag" HeaderText="Suspicous" HeaderButtonType="TextButton" FilterDelay="8000" CurrentFilterFunction="EqualTo"
                    DataField="SuspActivityFlag" UniqueName="MO_SuspActivityFlag" AutoPostBackOnFilter="false" ShowFilterIcon="false" AllowFiltering="false">
                    <ItemTemplate>
                            <asp:LinkButton ID="MOSuspActlbl" runat="server" Text='<%# Eval("SuspActivityFlag").ToString() == "Y" ? "Yes" : "No" %>'
                                ForeColor='<%# Eval("SuspActivityFlag").ToString() == "Y" ? System.Drawing.Color.Maroon : System.Drawing.Color.Black %>' URL='<%# Eval("suspLink") %>' OnClientClick="PopUp(this.URL);"></asp:LinkButton>
                        <telerik:RadScriptBlock ID="popupScript" runat="server">
                            <script type="text/javascript">
                                function PopUp(URL) {                                   
                                    if (URL != '') {
                                        day = new Date();
                                        id = day.getTime();
                                        window.open(URL, id, 'toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=850,height=700,left = 62,top = 15')
                                    }
                                }
                            </script>
                        </telerik:RadScriptBlock>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>              
                <telerik:GridTemplateColumn SortExpression="LogID" HeaderText="Log ID" GroupByExpression="LogID Group By LogID" HeaderButtonType="TextButton" FilterDelay="8000" CurrentFilterFunction="EqualTo"
                    DataField="LogID" UniqueName="MO_LogID" AutoPostBackOnFilter="false" ShowFilterIcon="true" AllowFiltering="true">
                    <ItemTemplate>
                        <asp:LinkButton ID="logLink" runat="server" Text='<%# Convert.ToInt32(Eval("LogID")) == -1 ? "N/A" : Eval("LogID") %>'
                            URL='<%# Eval("LogLink") %>' OnClientClick="PopUp(this.URL);"></asp:LinkButton>
                    </ItemTemplate>   
                </telerik:GridTemplateColumn>                                                           
                <telerik:GridBoundColumn SortExpression="UserName" HeaderText="User" HeaderButtonType="TextButton" FilterDelay="8000" CurrentFilterFunction="Contains"
                    DataField="UserName" UniqueName="MO_UserName" AutoPostBackOnFilter="false" ShowFilterIcon="false" AllowFiltering="true"></telerik:GridBoundColumn>                                                           
                <telerik:GridBoundColumn SortExpression="DateAdd" HeaderText="Date" HeaderButtonType="TextButton" FilterDelay="8000" DataField="DateAdd"
                    UniqueName="MO_DateAdd" AutoPostBackOnFilter="false" ShowFilterIcon="true" AllowFiltering="true" DataFormatString="{0:MM/dd/yyyy hh:mm tt}"></telerik:GridBoundColumn>                                                           
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <asp:ObjectDataSource ID="statusSource" runat="server" SelectMethod="GetStatuses"
        TypeName="MO.Business.Defaults">
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="locationSource" runat="server" SelectMethod="GetLocations"
        TypeName="MO.Business.Defaults">
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="histSource" runat="server" SelectMethod="GetHistory"
        TypeName="MO.Business.Research"></asp:ObjectDataSource>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">
</asp:Content>

I keep getting Cannot Find Column [MOID].  The stack trace looks like this:

[EvaluateException: Cannot find column [MOID].]
   System.Data.NameNode.Bind(DataTable table, List`1 list) +1173813
   System.Data.BinaryNode.Bind(DataTable table, List`1 list) +31
   System.Data.UnaryNode.Bind(DataTable table, List`1 list) +29
   System.Data.BinaryNode.Bind(DataTable table, List`1 list) +31
   System.Data.UnaryNode.Bind(DataTable table, List`1 list) +29
   System.Data.DataExpression.Bind(DataTable table) +59
   System.Data.DataExpression..ctor(DataTable table, String expression, Type type) +4833511
   System.Data.DataView.set_RowFilter(String value) +153
   System.Data.LinqDataView.set_RowFilter(String value) +53
   Telerik.Web.UI.GridEnumerableFromDataView.PerformTransformation() +405
   Telerik.Web.UI.GridEnumerableFromDataView.TransformEnumerable() +21

Thanks,
Aaron
Iana Tsolova
Telerik team
 answered on 24 Jun 2011
3 answers
230 views

Hi,

I want to have range on data field in DataTable in RadGrid, such DateTime, int, etc. How to get the range of them, such as min and max datetime and int?

Thanks.

Veli
Telerik team
 answered on 24 Jun 2011
1 answer
100 views
Hello ,

  I am facing a proble  when i am try to modify my child row in RAD Grid. following the my code base of gridl

<

 

 

telerik:RadGrid ID="rgSortCodes" runat="server"

 

 

 

OnItemDataBound="rgSortCodes_ItemDataBound"

 

 

 

OnUpdateCommand="rgSortCodes_UpdateCommand" OnDeleteCommand="rgSortCodes_DeleteCommand"

 

 

 

OnEditCommand="rgSortCodes_EditCommand" OnPageIndexChanged="rgSortCodes_PageIndexChanged"

 

 

 

OnPageSizeChanged="rgSortCodes_PageSizeChanged" OnCancelCommand="rgSortCodes_CancelCommand"

 

 

 

AllowPaging="True" PageSize="10" OnItemCreated="rgSortCodes_ItemCreated" ShowFooter="True"

 

 

 

GridLines="None" meta:resourcekey="rgSortCodesResource1" OnDetailTableDataBind="rgSortCodes_DetailTableBind" >

 

 

 

<ValidationSettings ValidationGroup="SortCodeGrid" />

 

 

 

<HeaderStyle HorizontalAlign="Center" />

 

 

 

<MasterTableView DataKeyNames="ID" AutoGenerateColumns="False" AllowAutomaticUpdates="true" AllowAutomaticDeletes="True" EditMode="InPlace" >

 

 

 

 

<DetailTables>

 

 

 

<telerik:GridTableView Width="50%" runat="server" EditMode="InPlace" AutoGenerateColumns="false" Name="Serial" ShowHeader="true" >

 

 

 

 

<ParentTableRelation>

 

 

 

<telerik:GridRelationFields MasterKeyField="ID" DetailKeyField="iSortID" />

 

 

 

</ParentTableRelation>

 

 

 

<Columns>

 

 

 

<telerik:GridBoundColumn Visible="true" DataField="ID"></telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn Visible="true" DataField="iSortID"></telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn Visible="true" DataField="ID"></telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn Visible="true" DataField="ID"></telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn Visible="true" DataField="ID"></telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn Visible="true" DataField="ID"></telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn Visible="true" DataField="ID"></telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn Visible="true" DataField="ID"></telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn Visible="true" DataField="ID"></telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn Visible="true" DataField="ID"></telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn Visible="true" DataField="ID"></telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn Visible="true" DataField="ID"></telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn Visible="true" DataField="ID"></telerik:GridBoundColumn>

 

 

 

 

<telerik:GridTemplateColumn HeaderText="iSortID" UniqueName="iSortID">

 

 

 

<ItemTemplate>

 

 

 

<telerik:RadTextBox ID="txtSerialNumber" runat="server" MaxLength="30" Enabled="false" Text='<%# Bind("Serialnumber") %>'>

 

 

 

</telerik:RadTextBox>

 

 

 

</ItemTemplate>

 

 

 

<EditItemTemplate>

 

 

 

<telerik:RadTextBox ID="txtSerialNumberEdit" runat="server" MaxLength="30" Text='<%# Bind("Serialnumber") %>'>

 

 

 

</telerik:RadTextBox>

 

 

 

</EditItemTemplate>

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

<telerik:GridEditCommandColumn EditText="Modify"

 

 

 

UniqueName="EditColumn" ButtonType="PushButton">

 

 

 

<ItemStyle Wrap="False"></ItemStyle>

 

 

 

</telerik:GridEditCommandColumn>

 

 

 

 

<telerik:GridButtonColumn CommandName="Delete"

 

 

 

meta:resourcekey="GridButtonColumnResource1" Text="Delete" UniqueName="DeleteColumn" ButtonType="ImageButton" >

 

 

 

<ItemStyle Wrap="False"></ItemStyle>

 

 

 

</telerik:GridButtonColumn>

 

 

 

</Columns>

 

 

 

</telerik:GridTableView>

 

 

 

</DetailTables>

 

 

 

<EditItemTemplate>

 

<

 

 

asp:Literal ID="litNoSortCodes" runat="server" Text="No data to display"

 

 

 

meta:resourcekey="litNoSortCodesResource1"></asp:Literal>

 

 

</

 

 

EditItemTemplate>

 

<

 

 

commanditemsettings exporttopdftext="Export to Pdf"></commanditemsettings>

 

<

 

 

Columns>

 

<

 

 

telerik:GridBoundColumn Aggregate="Count" DataField="OrderLineNumber" HeaderText="Line #"

 

 

 

meta:resourcekey="GridBoundColumnResource1" ReadOnly="True"

 

 

 

UniqueName="OrderLineNumber"></telerik:GridBoundColumn>

 

<

 

 

telerik:GridBoundColumn DataField="Action" HeaderText="Action"

 

 

 

meta:resourcekey="GridBoundColumnResource2" ReadOnly="True" UniqueName="Action"></telerik:GridBoundColumn>

 

<

 

 

telerik:GridBoundColumn DataField="MatItem" HeaderText="Sort Code"

 

 

 

meta:resourcekey="GridBoundColumnResource3" ReadOnly="True"

 

 

 

UniqueName="MatItem"></telerik:GridBoundColumn>

 

 

<

 

 

telerik:GridTemplateColumn>

 

<

 

 

HeaderTemplate>Serial# rqd?</HeaderTemplate>

 

<

 

 

ItemTemplate>

 

<

 

 

asp:DropDownList ID="drpSerialRQD" runat="server" Enabled="false">

 

<

 

 

asp:ListItem>Y</asp:ListItem>

 

<

 

 

asp:ListItem Selected="True">N</asp:ListItem>

 

<

 

 

asp:ListItem>ER</asp:ListItem>

 

</

 

 

asp:DropDownList>

 

</

 

 

ItemTemplate>

 

</

 

 

telerik:GridTemplateColumn>

 

<

 

 

telerik:GridTemplateColumn>

 

<

 

 

HeaderTemplate>Serial Number</HeaderTemplate>

 

<

 

 

ItemTemplate>

 

<

 

 

asp:TextBox ID="txtGridSerialNumber" runat="server" Enabled="false"></asp:TextBox>

 

</

 

 

ItemTemplate>

 

</

 

 

telerik:GridTemplateColumn>

 

<

 

 

telerik:GridBoundColumn DataField="DescriptionE" HeaderText="Description"

 

 

 

meta:resourcekey="GridBoundColumnResource4" ReadOnly="True"

 

 

 

UniqueName="Description"></telerik:GridBoundColumn>

 

 

<

 

 

telerik:GridNumericColumn DataField="CurrentQuantity" HeaderText="Current Quantity"

 

 

 

meta:resourcekey="GridNumericColumnResource1" ReadOnly="True"

 

 

 

UniqueName="CurrentQuantity"></telerik:GridNumericColumn>

 

<

 

 

telerik:GridNumericColumn DataField="RevisedQuantity"

 

 

 

HeaderText="Revised Quantity" meta:resourcekey="GridNumericColumnResource2"

 

 

 

UniqueName="RevisedQuantity"></telerik:GridNumericColumn>

 

<

 

 

telerik:GridNumericColumn DataField="UnitPrice" HeaderText="Unit Price"

 

 

 

meta:resourcekey="GridNumericColumnResource3" NumericType="Currency"

 

 

 

UniqueName="UnitPrice"></telerik:GridNumericColumn>

 

<

 

 

telerik:GridBoundColumn DataField="SAPLineNumber" HeaderText="SAP Line Number"

 

 

 

meta:resourcekey="GridBoundColumnResource12" ReadOnly="True"

 

 

 

UniqueName="SAPLineNumber"></telerik:GridBoundColumn>

 

<

 

 

telerik:GridEditCommandColumn EditText="Modify"

 

 

 

meta:resourcekey="GridEditCommandColumnResource1" UniqueName="EditColumn" ButtonType="PushButton">

 

 

 

<ItemStyle Wrap="False"></ItemStyle>

 

</

 

 

telerik:GridEditCommandColumn>

 

<

 

 

telerik:GridButtonColumn CommandName="Delete"

 

 

 

meta:resourcekey="GridButtonColumnResource1" Text="Cancel" UniqueName="DeleteColumn" ButtonType="PushButton">

 

 

 

<ItemStyle Wrap="False"></ItemStyle>

 

</

 

 

telerik:GridButtonColumn>

 

</

 

 

Columns>

 

</

 

 

MasterTableView>

 

</

 

 

telerik:RadGrid>

 




when i am try to click on the child's Modify button i am getting

Line: 938
Error: Sys.WebForms.PageRequestManagerServerErrorException: Cannot find column [iSortID]


I did all left right to find the solution.

Please help on this

Regards
Pradeep
Iana Tsolova
Telerik team
 answered on 24 Jun 2011
3 answers
138 views
I am trying to use a rad listview contol to display data from a SQL data table.  When the data is loading (binding) I need to examine the data columns and perform some modifications to the data and replace the value in one of the data fields with the modified data.  For example, there are three fields of data in the underlying query.  Field 'A' contains 'abc'.  Field 'B' contains '123'. Field 'C' contains an empty string.  I want to concatenate the contents of Fields 'A' and 'B' and the place the results 'abc123' in Field 'C' which is defined in the listview layout.

I do these (and other) sorts of modifications to data regularly when using the rad grid.  Can I do them when using your listview control as well?

When performing these operations in the grid, I use the "ItemDataBound" event and perform a test at the beginning of the event for "If TypeOf e.Item Is GridDataItem Then.....Else....End If" such as:

Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound
    If TypeOf e.Item Is GridDataItem Then
            sLat = ""
            sLong = ""
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        item("TextActive").Text = "Yes"
    End If
End Sub


I have tried doing something similar in the same event for the RadListView control, but always get errors -- you may refer to the attached screen capture.

Is there a way to modify the data to appear in the radlistview similarly to what I am doing with the radgrid?

Thanks in advance!

Lynn
Veli
Telerik team
 answered on 24 Jun 2011
3 answers
66 views
I have assigned multiple Group FilterExpressions to my ListView and am receiving the following error on postback:

"Index was out of range. Must be non-negative and less than the size of the collection."

Wondering if this indeed a bug or if I'm databinding my Listview incorrectly?  I'm using the NeedDataSource function of the ListView to load the data.  I have a button to "Apply Filter" that calls the RadListView1.Rebind method.  I've tried to trace but the error is thrown before any databinding occurs on the Listview (something to do with the Viewstate for the FilterExpressions on the ListView)?

Thanks for any help,
Jason
Veli
Telerik team
 answered on 24 Jun 2011
2 answers
56 views
Hi guys,

Does anyone know how to modify the Calendar Special Days from the JavaScript?
So it's like initially the special days contains 1 Day set to today, and then  I'd like to change it to tomorrow or any other date.

Thank you,
Best Regards,
Ronald Wisnu Hariyanto
Ronald
Top achievements
Rank 1
 answered on 24 Jun 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?