Telerik Forums
UI for ASP.NET AJAX Forum
0 answers
98 views
I've got a radgrid that has several levels of calculations - as the user drills down through groupings, calculations become more specific.  Inside the toplevel radgrid, I've got another radgrid inside of a nestedviewtemplate such as this:

<telerik:RadGrid>
<MasterTableView DataKeyNames="id" HierarchyLoadMode="ServerOnDemand" HierarchyDefaultExpanded="false">
<Columns>
</Columns>
<NestedViewTemplate>
<telerik:RadGrid>
</telerik:RadGrid>
</NestedViewTemplate>
</MasterTableView>
</telerik:RadGrid>

For every ExpandCollapse column or grid level, there is a padding that is introduced somehow (so that the nestedtemplate ui-wise appears as a child).  Is there anyway to override that in the css?  I can see that rgExpandCol is the class used to display the image, but I can see that my nested row contains a table cell with class rgExpandCol but no image is actually visible.  Basically, I need my nested templates to expand to 100% of the width if at all possible.  Any suggestions?
debbie f
Top achievements
Rank 1
 asked on 07 Aug 2012
0 answers
90 views
I have an Update button in template editForm. My problem is that I cannot implement the button. I have seen this demo (http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx) and tried to implement the RadGrid1_UpdateCommand event handler, but I got compilation errors for this line:

DataRow[] changedRows = this.UserDataSource.Select("user_id = " + editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Users"]);

The errors are:
1. "The best overloaded method match for 'System.Web.UI.WebControls.SqlDataSource.Select(System.Web.UI.DataSourceSelectArguments)' has some invalid arguments"
2. "Argument 1: cannot convert from 'string' to 'System.Web.UI.DataSourceSelectArguments'"

Can anyone help me on this?

Here's the code for the UpdateCommand event handler:
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
{
   GridEditableItem editedItem = e.Item as GridEditableItem;
   UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
 
   //Prepare new row to add it in the DataSource
   DataRow[] changedRows = this.UserDataSource.Select("user_id = " + 
        editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Users"]);
 
// in progress. to be implemented here
}
Iris
Top achievements
Rank 1
 asked on 07 Aug 2012
0 answers
106 views
Line: 9
Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '

When I click on add record it gives me the above error.



<%@ Page Title="" Language="C#" MasterPageFile="~/App_MasterPages/OneColumnMasterPage.Master"
    AutoEventWireup="true" CodeBehind="AddModifyType.aspx.cs" Inherits="Schedule.Administration.AddModifyType" %>
  
<asp:Content ID="Content1" ContentPlaceHolderID="HeadPlaceHolder" runat="server">
    <style type="text/css">
        .EditFormHeader td
        {
            font-size: 14px;
            padding: 4px !important;
            font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
            color: #646882;
            text-decoration: none;
            font-weight: bold;
            height: 22px;
            border: 1 px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <br />
    <table cellpadding="3" cellspacing="0" border="0" style="width: 100%;">
        <tr>
            <td id="header">
                <SCHEDULE:uxPageTitle ID="uxPageTitle" Title="Add/Modify Type" runat="server"></SCHEDULE:uxPageTitle>
                <table border="0" cellpadding="0" cellspacing="0" width="100%" class="box">
                    <tr class="boxTop">
                        <td>
                            <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
                            </telerik:RadCodeBlock>
                            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                                <AjaxSettings>
                                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                                        <UpdatedControls>
                                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                                            <telerik:AjaxUpdatedControl ControlID="divMsgs" />
                                        </UpdatedControls>
                                    </telerik:AjaxSetting>
                                </AjaxSettings>
                            </telerik:RadAjaxManager>
                            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
                            </telerik:RadAjaxLoadingPanel>
                            <input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex" />
                            <telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                                Skin="Windows7" AllowPaging="True" ShowStatusBar="True" OnPreRender="RadGrid1_PreRender"
                                OnNeedDataSource="RadGrid1_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand"
                                OnInsertCommand="RadGrid1_InsertCommand" OnDeleteCommand="RadGrid1_DeleteCommand"
                                CellSpacing="0" GridLines="None" OnItemCreated="RadGrid1_ItemCreated" 
                                OnItemDataBound="RadGrid1_ItemDataBound" onitemcommand="RadGrid1_ItemCommand">
                                <HeaderStyle Font-Bold="True" Font-Size="9pt"></HeaderStyle>
                                <ItemStyle Font-Size="8.5pt" />
                                <AlternatingItemStyle Font-Size="8.5pt" />
                                <PagerStyle Mode="NextPrevAndNumeric" />
                                <ClientSettings>
                                    <Selecting AllowRowSelect="True"></Selecting>
                                </ClientSettings>
                                <ClientSettings>
                                    <Selecting CellSelectionMode="None" AllowRowSelect="True"></Selecting>
                                </ClientSettings>
                                <MasterTableView Width="100%" TableLayout="Auto" CommandItemDisplay="Top" DataKeyNames="Type">
                                    <Columns>
                                        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"
                                            HeaderStyle-Width="24" EditImageUrl="../Skins/Outlook/Grid/Edit.gif">
                                        </telerik:GridEditCommandColumn>
                                        <telerik:GridBoundColumn DataField="Type" DataType="System.Int32" ItemStyle-Width="7px"
                                            HeaderText="Type" SortExpression="Type" UniqueName="Type">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="TypeDescription" ItemStyle-Width="220px" HeaderText="Description"
                                            SortExpression="TypeDescription" UniqueName="TypeDescription">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="MinLbsGVW" ItemStyle-Width="15px" HeaderText="Min Lbs GVW"
                                            SortExpression="MinLbsGVW" UniqueName="MinLbsGVW">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="MaxLbsGVW" ItemStyle-Width="15px" HeaderText="Max Lbs GVW"
                                            SortExpression="MaxLbsGVW" UniqueName="MaxLbsGVW">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ReportClassification" ItemStyle-Width="95px"
                                            HeaderText="Report Class" SortExpression="ReportClassification" UniqueName="ReportClassification">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="L_H_S" ItemStyle-Width="10px" HeaderText="L/H/S"
                                            SortExpression="L_H_S" UniqueName="L_H_S">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="RepModel" ItemStyle-Width="40px" HeaderText="Replacement Model"
                                            SortExpression="RepModel" UniqueName="RepModel">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="AmortizationClassification" HeaderText="Amortization Class"
                                            SortExpression="AmortizationClassification" ItemStyle-Width="60px" UniqueName="AmortizationClassification">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="CountClass" ItemStyle-Width="10px" HeaderText="Count Class"
                                            SortExpression="CountClass" UniqueName="CountClass">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="RepCost" DataType="System.Decimal" ItemStyle-Width="60px"
                                            DataFormatString="{0:C}" HeaderText="Replacement Cost" SortExpression="RepCost"
                                            UniqueName="RepCost">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="LeadTimeRequired" HeaderText="Lead Time" SortExpression="LeadTimeRequired"
                                            Visible="false" UniqueName="LeadTimeRequired">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridCheckBoxColumn DataField="HasTires" DataType="System.Boolean" ItemStyle-Width="10px"
                                            HeaderText="Tires" SortExpression="HasTires" UniqueName="HasTires">
                                        </telerik:GridCheckBoxColumn>
                                        <telerik:GridCheckBoxColumn DataField="FirstAidKitRequired" DataType="System.Boolean"
                                            ItemStyle-Width="10px" HeaderText="First Aid" SortExpression="FirstAidKitRequired"
                                            UniqueName="FirstAidKitRequired">
                                        </telerik:GridCheckBoxColumn>
                                        <telerik:GridBoundColumn DataField="FireExtinguisherSize" Visible="false" HeaderText="Fire Exting. Size"
                                            SortExpression="FireExtinguisherSize" UniqueName="FireExtinguisherSize">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="CAMFM" ItemStyle-Width="17px" HeaderText="CAMFM"
                                            SortExpression="CAMFM" UniqueName="CAMFM">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="EffectiveDate" DataType="System.DateTime" DataFormatString="{0:yyyy/MM/dd}"
                                            ItemStyle-Width="20px" HeaderText="Effective Date" SortExpression="EffectiveDate"
                                            Visible="false" UniqueName="EffectiveDate">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="CreatorID" Visible="false" ReadOnly="true" HeaderText="CreatorID"
                                            SortExpression="CreatorID" UniqueName="CreatorID">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="LastModifyID" Visible="false" ReadOnly="true"
                                            HeaderText="Modify By" SortExpression="LastModifyID" UniqueName="LastModifyID">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="LastModifyTime" Visible="false" ReadOnly="true"
                                            DataType="System.DateTime" HeaderText="Modify Time" SortExpression="LastModifyTime"
                                            UniqueName="LastModifyTime">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this record?"
                                            ButtonType="ImageButton" ImageUrl="../Skins/Outlook/Grid/Delete.gif" CommandName="Delete"
                                            Text="Delete" UniqueName="DeleteColumn">
                                            <HeaderStyle Width="20px" />
                                        </telerik:GridButtonColumn>
                                    </Columns>
                                    <EditFormSettings UserControlName="~/Controls/Type/uxAddModifyType.ascx" EditFormType="WebUserControl">
                                        <EditColumn UniqueName="EditCommandColumn1">
                                        </EditColumn>
                                    </EditFormSettings>
                                </MasterTableView>
                                <FilterMenu EnableImageSprites="False">
                                </FilterMenu>
                            </telerik:RadGrid>
                            <br />
                            <br />
                            <p id="divMsgs" runat="server">
                                  <asp:Label ID="Label1" runat="server" EnableViewState="False" Font-Bold="True"
                                    ForeColor="#FF8080"></asp:Label>
                                  <asp:Label ID="Label2" runat="server" EnableViewState="False" Font-Bold="True"
                                    ForeColor="#00C000"></asp:Label>
                            </p>
                            <br />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ModalPlaceHolder" runat="server">
</asp:Content>
  
using System;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Data;
using System.Collections;
using System.Configuration;
using System.Data.SqlClient;
using System.Globalization;
using System.Security.Principal;
using Schedule.Helpers;
  
namespace Schedule.Administration
{
    public partial class AddModifyType : ScheduleBasePage
    {
          #region Data members
  
  
        #endregion
  
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
  
  
            }
  
        }
  
        private static DataTable GetDataTable(string queryString)
        {
            String ConnString = ConfigurationManager.ConnectionStrings["MinotaurConnectionString"].ConnectionString;
            SqlConnection MySqlConnection = new SqlConnection(ConnString);
            SqlDataAdapter MySqlDataAdapter = new SqlDataAdapter();
            MySqlDataAdapter.SelectCommand = new SqlCommand(queryString, MySqlConnection);
  
            DataTable myDataTable = new DataTable();
            MySqlConnection.Open();
            try
            {
                MySqlDataAdapter.Fill(myDataTable);
            }
            finally
            {
                MySqlConnection.Close();
            }
  
            return myDataTable;
        }
  
        protected void RadGrid1_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            string ID = (e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Type"].ToString();
            DataTable typeTable = this.SqlDataSourceTypesDataTable;
            try
            {
                if (typeTable.Rows.Find(ID) != null)
                {
                    typeTable.Rows.Find(ID).Delete();
                    typeTable.AcceptChanges();
                    DisplayMessage(false, "Your Type has been deleted successfully!");
                }
            }
            catch (Exception ex)
            {
  
                DisplayMessage(true, "Your Type could not be deleted. Reason: " + ex.Message);
                e.Canceled = true;
            }
  
  
        }
  
        private DataTable SqlDataSourceTypesDataTable
        {
            get
            {
                object obj = this.Session["ModifyTypes"];
                if ((!(obj == null)))
                {
                    return ((DataTable)(obj));
                }
                DataTable myDataTable = new DataTable();
                myDataTable = GetDataTable("SELECT Type, TypeDescription, MinLbsGVW, MaxLbsGVW, ReportClassification, [L/H/S], RepModel, AmortizationClassification, CountClass,RepCost, LeadTimeRequired, HasTires, FirstAidKitRequired, CAMFM, EffectiveDate, CreatorID, LastModifyID, LastModifyTime from Types");
                this.Session["ModifyTypes"] = myDataTable;
                return myDataTable;
            }
        }
  
  
        protected void RadGrid1_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
            int rowindex = editedItem.ItemIndex;  //Row index to identify the row edited
  
  
            String selectQuery = String.Format("Type='{0}'",
            editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Type"]);
  
  
            DataRow[] changedRows = this.SqlDataSourceTypesDataTable.Select(selectQuery);
  
            if (changedRows.Length != 1)
            {
                RadGrid1.Controls.Add(new LiteralControl("Unable to locate the row for updating."));
                e.Canceled = true;
                return;
            }
  
            string domainUser = null;
            WindowsIdentity userName = WindowsIdentity.GetCurrent();
  
  
            if (userName != null)
            {
                domainUser = StringManipulation.ExtractUserName(userName.Name.ToString());
            }
  
            //Update new values
            Hashtable newValues = new Hashtable();
            newValues["Type"] = (userControl.FindControl("txtTypeNumber") as TextBox).Text;
            newValues["TypeDescription"] = (userControl.FindControl("txtTypeDescription") as TextBox).Text;
            newValues["MinLbsGVW"] = (userControl.FindControl("txtMinLbsGVW") as TextBox).Text;
            newValues["MaxLbsGVW"] = (userControl.FindControl("txtMaxLbsGVW") as TextBox).Text;
            newValues["ReportClassification"] = (userControl.FindControl("txtReportClassification") as TextBox).Text;
            newValues["L/H/S"] = (userControl.FindControl("txtLHS") as TextBox).Text;
            newValues["RepModel"] = (userControl.FindControl("txtReplacementModel") as TextBox).Text;
            newValues["AmortizationClassification"] = (userControl.FindControl("txtAmortization") as TextBox).Text;
            newValues["CountClass"] = (userControl.FindControl("txtCountClass") as TextBox).Text;
            newValues["RepCost"] = double.Parse(((userControl.FindControl("txtReplacementCost") as TextBox).Text), NumberStyles.Currency); 
            newValues["LeadTimeRequired"] = 0;
            newValues["HasTires"] = (userControl.FindControl("chkHasTires") as CheckBox).Checked;
            newValues["FirstAidKitRequired"] = (userControl.FindControl("chkFirstAid") as CheckBox).Checked;
            newValues["CAMFM"] = (userControl.FindControl("txtCAMFM") as TextBox).Text;
            newValues["EffectiveDate"] = (userControl.FindControl("lblEffectiveDate") as Label).Text;
            newValues["CreatorID"] = (userControl.FindControl("lblEffectiveDate") as Label).Text;
            newValues["LastModifyID"] = domainUser;// (userControl.FindControl("lblModifiedBy") as Label).Text;
            newValues["LastModifyTime"] = DateTime.Now;
  
            changedRows[0].BeginEdit();
            try
            {
                foreach (DictionaryEntry entry in newValues)
                {
                    changedRows[0][(string)entry.Key] = entry.Value;
                }
                changedRows[0].EndEdit();
                this.SqlDataSourceTypesDataTable.AcceptChanges();
  
                DisplayMessage(false, "Your Type has been updated successfully!");
  
            }
            catch (Exception ex)
            {
  
                changedRows[0].CancelEdit();
                DisplayMessage(true, "Your Type could not be updated. Reason: " + ex.Message);
                e.Canceled = true;
            }
  
  
        }
  
        private void DisplayMessage(bool isError, string text)
        {
            Label label = (isError) ? this.Label1 : this.Label2;
            label.Text = text;
        }
  
  
        protected void RadGrid1_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.PerformInsertCommandName)
            {
  
                GridEditableItem editedItem = e.Item as GridEditableItem;
                UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
  
                //Create new row in the DataSource
                DataRow newRow = this.SqlDataSourceTypesDataTable.NewRow();
  
  
                string domainUser = null;
                WindowsIdentity userName = WindowsIdentity.GetCurrent();
  
  
                if (userName != null)
                {
                    domainUser = StringManipulation.ExtractUserName(userName.Name.ToString());
                }
  
                //Insert new values
                Hashtable newValues = new Hashtable();
                newValues["Type"] = (userControl.FindControl("txtTypeNumber") as TextBox).Text;
                newValues["TypeDescription"] = (userControl.FindControl("txtTypeDescription") as TextBox).Text;
                newValues["MinLbsGVW"] = (userControl.FindControl("txtMinLbsGVW") as TextBox).Text;
                newValues["MaxLbsGVW"] = (userControl.FindControl("txtMaxLbsGVW") as TextBox).Text;
                newValues["ReportClassification"] = (userControl.FindControl("txtReportClassification") as TextBox).Text;
                newValues["L/H/S"] = (userControl.FindControl("txtLHS") as TextBox).Text;
                newValues["RepModel"] = (userControl.FindControl("txtReplacementModel") as TextBox).Text;
                newValues["AmortizationClassification"] = (userControl.FindControl("txtAmortization") as TextBox).Text;
                newValues["CountClass"] = (userControl.FindControl("txtCountClass") as TextBox).Text;
                newValues["RepCost"] = double.Parse(((userControl.FindControl("txtReplacementCost") as TextBox).Text), NumberStyles.Currency);
                newValues["LeadTimeRequired"] = 0;
                newValues["HasTires"] = (userControl.FindControl("chkHasTires") as CheckBox).Checked;
                newValues["FirstAidKitRequired"] = (userControl.FindControl("chkFirstAid") as CheckBox).Checked;
                newValues["CAMFM"] = (userControl.FindControl("txtCAMFM") as TextBox).Text;
                newValues["EffectiveDate"] = (userControl.FindControl("lblEffectiveDate") as Label).Text;
                newValues["CreatorID"] = domainUser; // (userControl.FindControl("lblEffectiveDate") as Label).Text;
                newValues["LastModifyID"] = domainUser; // (userControl.FindControl("lblModifiedBy") as Label).Text;
                newValues["LastModifyTime"] = DateTime.Now;
  
  
                ////make sure that unique primary key value is generated for the inserted row 
                // newValues["Type"] = (int)this.SqlDataSourceTypeDataTable.Rows[this.SqlDataSourceTypeDataTable.Rows.Count - 1]["Type"] + 1;
  
  
  
                try
                {
                    foreach (DictionaryEntry entry in newValues)
                    {
                        newRow[(string)entry.Key] = entry.Value;
                    }
                    this.SqlDataSourceTypesDataTable.Rows.Add(newRow);
                    this.SqlDataSourceTypesDataTable.AcceptChanges();
  
                    DisplayMessage(false, "Your Type has been inserted successfully!");
  
                }
                catch (Exception ex)
                {
  
                    DisplayMessage(true, "Your Type could not be inserted. Reason: " + ex.Message);
                    e.Canceled = true;
                }
            }
        }
  
        protected void RadGrid1_PreRender(object sender, System.EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.RadGrid1.MasterTableView.Items[1].Edit = true;
                this.RadGrid1.MasterTableView.Rebind();
            }
        }
  
  
        protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
        {
            if (e.Column.IsBoundToFieldName("Date"))
            {
                (e.Column as GridDateTimeColumn).DataFormatString = "{0:D}";
            }
            else if (e.Column.IsBoundToFieldName("UnitPrice"))
            {
                (e.Column as GridNumericColumn).DataFormatString = "{0:C}";
            }
            if (e.Column is GridBoundColumn)
            {
                (e.Column as GridBoundColumn).FilterControlWidth = System.Web.UI.WebControls.Unit.Pixel(100);
            }
        }
  
        protected void RadGrid1_EditCommand(object sender, GridCommandEventArgs e)
        {
  
        }
  
        protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            this.RadGrid1.DataSource = this.SqlDataSourceTypesDataTable;
            this.SqlDataSourceTypesDataTable.PrimaryKey = new DataColumn[] 
                {
                  this.SqlDataSourceTypesDataTable.Columns["Type"]
                };
  
        }
  
        protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            //if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
            //{
            //    UserControl MyUserControl = e.Item.FindControl(GridEditFormItem.EditFormUserControlID) as UserControl;
            //    string script = String.Format("$get('{0}').focus(); $get('{0}').select();", MyUserControl.FindControl("TextBox7").ClientID);
            //    ScriptManager.RegisterStartupScript(Page, typeof(Page), "myscript", script, true);
            //}
  
             
  
        }
  
        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                GridEditableItem editedItem = e.Item as GridEditableItem;
                UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
                TextBox dataField = (userControl.FindControl("txtTypeDescription") as TextBox); 
                dataField.Focus();
            }
        }
  
        protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.InitInsertCommandName)
            {
                //Add new" button clicked
                e.Canceled = true;
                //Prepare an IDictionary with the predefined values
                System.Collections.Specialized.ListDictionary newValues = new
                System.Collections.Specialized.ListDictionary();
                newValues["Type"] = "0";
                //Insert the item and rebind
                e.Item.OwnerTableView.InsertItem(newValues);
            }
  
        }
  
  
  
    }
  
     
}
mathieu cupryk
Top achievements
Rank 1
 asked on 07 Aug 2012
0 answers
81 views
I need do this
http://www.telerik.com/help/aspnet-ajax/grid-commanditemtemplate.html 

Delete Selected ...
But I use resources for popus....

I need load a Popup from server side, then if user click on "OK", delete selected rows!

How  can  I do this?
July
Top achievements
Rank 2
 asked on 06 Aug 2012
2 answers
128 views
I've recently upgraded our application to .net 4.0 and since then the popup calendar has basically stopped working.

See: http://freeport.ss.syntaxcom.com/calendar/calendarview.aspx?group=&RequestedDate=8/1/2012&RequestedCalendar=monthgrid

The popup displays, but the header is behind the monthview day headers and you cannot select the mini-calendar dates as it's technically displaying behind the monthview's day entries.

I've tried various css options with no success.  I've seen this issue has popped up before in the forums, but I've not found a solution that works.  Any ideas?

Note: The current version of Telerik in the project is: 2012.2.724.40
Janean Angeles
Top achievements
Rank 1
 answered on 06 Aug 2012
0 answers
93 views
I implemented a simple TabStrip/Wizard control as shown in this demo http://demos.telerik.com/aspnet-ajax/tabstrip/examples/applicationscenarios/wizard/defaultcs.aspx 

I have one aspx with rad TabStrip and three ascx pages that feed the content of each tab. When the parent page is opened, the content of the first tab loads from the associated user control with no error. When I click next to navigate to the second tab, however, the below error occurs.

Is there something special I need to do in order for this to work in SharePoint 2010 application page?

Any help is much appreciated,

Thanks,
Ibsa

Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB7.3; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MDDR; .NET4.0C; .NET4.0E; InfoPath.2)
Timestamp: <time>

Message: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
Line: 4723
Char: 21
Code: 0
URI: http://<server-name>/ScriptResource.axd?d=oxveds8lFOxv5Jc_vbLat_faNgPVzPdfeB0qCW2XezdNMjthEgXqrFCPb3GgVTLPaFSVq-wtsnpHOHDRcGQhwTt8eJiQT7-4eYDP4wCVj0dY7mlDgUNo8OpFQgy2jPFWXfv2ZbjY9M3pqKTBzAoCrGx1FQPzT-koBUUT3efDYAsF7WRA0&t=ffffffffb868b5f4 


Parent aspx page:

<div class="exampleWrapper"> 
<telerik:RadAjaxLoadingPanel runat="server" ID="LoadingPanel1">
    </telerik:RadAjaxLoadingPanel>       
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="LoadingPanel1" Height="100%">
        <div style="float:left; width:500px">
            <telerik:RadTabStrip ID="RadTabStrip1" SelectedIndex="0" runat="server" MultiPageID="RadMultiPage1"
                Skin="Sunset" CssClass="tabStrip">
            </telerik:RadTabStrip>
            <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0" OnPageViewCreated="RadMultiPage1_PageViewCreated" CssClass="multiPage">
            </telerik:RadMultiPage>
        </div>
   </telerik:RadAjaxPanel>
</div>
protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                AddTab("Personal Info", true);
 
                RadPageView pageView = new RadPageView();
                pageView.ID = "Personal";
                RadMultiPage1.PageViews.Add(pageView);
 
                AddTab("Education Info", false);
                AddTab("Professional Info", false);
            }
        }
 
        private void AddTab(string tabName, bool enabled)
        {
            RadTab tab = new RadTab(tabName);
            tab.Enabled = enabled;
            RadTabStrip1.Tabs.Add(tab);
        }
 
        protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
        {
            Control pageViewContents = LoadControl(e.PageView.ID + "CS.ascx");
            pageViewContents.ID = e.PageView.ID + "userControl";
 
            e.PageView.Controls.Add(pageViewContents);
        }

User Control for Tab1
<asp:Button runat="server" ID="nextButton" Text="Next" OnClick="nextButton_Click" CssClass="nextButton" />
protected void nextButton_Click(object sender, EventArgs e)
        {
            GoToNextTab();
        }
 
        private void GoToNextTab()
        {
            RadTabStrip tabStrip = (RadTabStrip)Page.FindControl("RadTabStrip1");
            RadTab educationInfoTab = tabStrip.FindTabByText("Education Info");
            educationInfoTab.Enabled = true;
            educationInfoTab.Selected = true;
 
            GoToNextPageView();
        }
 
        private void GoToNextPageView()
        {
            RadMultiPage multiPage = (RadMultiPage)Page.FindControl("RadMultiPage1");
            RadPageView educationInfoPageView = multiPage.FindPageViewByID("Education");
            if (educationInfoPageView == null)
            {
                educationInfoPageView = new RadPageView();
                educationInfoPageView.ID = "Education";
                multiPage.PageViews.Add(educationInfoPageView);
            }
            educationInfoPageView.Selected = true;
        }

Ibsa
Top achievements
Rank 1
 asked on 06 Aug 2012
2 answers
199 views
I have a RadGrid using a CommandItemTemplate wrapped in an RadAjaxPanel:

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="RequestStart" ClientEvents-OnResponseEnd="ResponseEnd" LoadingPanelID="RadAjaxLoadingPanel1">
    <telerik:RadGrid ID="AccountGrid1" runat="server" OnNeedDataSource="AccountGrid1_NeedDataSource"
                    OnSortCommand="AccountGrid1_SortCommand" OnGroupsChanging="AccountGrid1_GroupsChanging" OnColumnCreated="AccountGrid1_ColumnCreated" OnItemCreated="AccountGrid1_ItemCreated"
                    AutoGenerateColumns="true" AllowPaging="true" AllowCustomPaging="true" AllowSorting="true" GroupingEnabled="true"
                    ShowGroupPanel="true" ShowFooter="true" ShowHeader="true">
        <GroupingSettings CaseSensitive="false"  />
        <MasterTableView DataKeyNames="Id,ClientId" ClientDataKeyNames="Id" AllowNaturalSort="false"
         AllowMultiColumnSorting="false" AllowCustomSorting="true" CommandItemDisplay="Top">
            <CommandItemStyle HorizontalAlign="Right" />
            <CommandItemTemplate>
                <asp:LinkButton ID="RefreshLinkButton" runat="server" CommandName="RebindGrid"><%= Navigator.Icon("Refresh", "refresh").ToHtmlImage() %> Refresh</asp:LinkButton>  |  
                <telerik:RadComboBox ID="gridStatCombo" runat="server" OnClientSelectedIndexChanged="EnableStatButton" DropDownWidth="250" Visible="false">
                    <Items>
                        <telerik:RadComboBoxItem Text="Select a field to group by" Value="" />
 
                    </Items>
                </telerik:RadComboBox>
                <telerik:RadComboBox ID="gridStatDateCombo" runat="server" Width="75" Visible="false" Enabled="false">
                    <Items>
                        <telerik:RadComboBoxItem Text="Day" Value="DAY" />
                        <telerik:RadComboBoxItem Text="Month" Value="MONTH" Selected="true" />
                        <telerik:RadComboBoxItem Text="Year" Value="YEAR" />
                    </Items>
                </telerik:RadComboBox>
                <telerik:RadButton ID="gridStatBtn" runat="server" Text="View Statistics" OnClick="Stat_Click" Enabled="false" Visible="false" />  |  
 
                <telerik:RadComboBox ID="gridExportCombo" runat="server" OnClientSelectedIndexChanged="EnableExportButton" DropDownWidth="250">
                    <Items>
                        <telerik:RadComboBoxItem Text="Select an export format" Value="" />
                        <telerik:RadComboBoxItem Text="Excel" Value="Excel" ImageUrl="~/Main/Content/Images/Icons/excel.png" />
                        <telerik:RadComboBoxItem Text="Word" Value="Word" ImageUrl="~/Main/Content/Images/Icons/ms_word_2.png" />
                        <telerik:RadComboBoxItem Text="PDF" Value="PDF" ImageUrl="~/Main/Content/Images/Icons/filetype_pdf.png" />
                        <telerik:RadComboBoxItem Text="Comma Separated Values (CSV)" Value="CSV" ImageUrl="~/Main/Content/Images/Icons/csv_file.png" />
                        <telerik:RadComboBoxItem Text="Tab-delimited" Value="Tab" ImageUrl="~/Main/Content/Images/Icons/txt_file.png" />
                        <telerik:RadComboBoxItem Text="Tab-delimited w/ Quotes" Value="TabQuote" ImageUrl="~/Main/Content/Images/Icons/txt_file.png" />
                    </Items>
                </telerik:RadComboBox>
                <telerik:RadButton ID="gridBtnExport" runat="server" Text="Export" OnClick="Export_Click" Enabled="false" />
            </CommandItemTemplate>
            <PagerStyle AlwaysVisible="true" />
        </MasterTableView>
        <ClientSettings AllowDragToGroup="true" AllowColumnsReorder="true">
            <Selecting AllowRowSelect="true" />
            <ClientEvents OnRowDblClick="ViewAccount" OnGridCreated="ResizeAccountGrid" />
            <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="100%" />
        </ClientSettings>
        <GroupingSettings ShowUnGroupButton="true" />
        <FooterStyle HorizontalAlign="Right" />
        <ExportSettings ExportOnlyData="true" HideStructureColumns="true" IgnorePaging="true"/>
    </telerik:RadGrid>
 
    <telerik:RadScriptBlock ID="AccountGridScriptBlock" runat="server">
        <script type="text/javascript">
            $(window).resize(function () { ResizeAccountGrid(); });
 
            function ResizeAccountGrid(sender, eventArgs) {
                ResizeGrid($find("<%= AccountGrid1.ClientID %>"));
            }
 
            function ViewAccount(sender, eventArgs) {
                var accountId = eventArgs.get_gridDataItem().getDataKeyValue("Id");
                ToolClick(null, null, "<%= Navigator.Inquiry() %>" + "?Id=" + accountId, "<%= (int)SiteNavigatorTab.Inquiry %>", false);
            }
 
            function RequestStart(sender, eventArgs) {
                //Log the start time
                startTime = new Date();
                if (eventArgs.EventTarget.indexOf("gridBtnExport") > 0) {
                    eventArgs.EnableAjax = false;
                }
            }
         
            function ResponseEnd(sender, eventArgs) {
                //Log the end time
                var endTime = new Date();
                //Display the total time
                //$get("<%= lblTotal.ClientID %>").innerHTML = endTime - startTime + " ms";
            }
         
            function EnableExportButton(sender, eventArgs) {
                var item = eventArgs.get_item();
                var button = $find('<%= (AccountGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0]).FindControl("gridBtnExport").ClientID %>');
                var selectedIndex = item.get_index();
                button.set_enabled(selectedIndex != 0);
            }
 
            function EnableStatButton(sender, eventArgs) {
                var item = eventArgs.get_item();
                var button = $find('<%= (AccountGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0]).FindControl("gridStatBtn").ClientID %>');
                var dateBreak = $find('<%= (AccountGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0]).FindControl("gridStatDateCombo").ClientID %>');
                var selectedIndex = item.get_index();
                button.set_enabled(selectedIndex != 0);
                var dateFields = "<%= JsDateTimeFields %>".split("|");
                var text = item.get_text();
                var exists = $.inArray(text, dateFields) > -1;
                dateBreak.set_enabled(exists);
            }
        </script>
    </telerik:RadScriptBlock>
</telerik:RadAjaxPanel>

The RadComboBox (id gridStatCombo) is populated server side in Page_Load:

protected void Page_Load(object sender, EventArgs e)
{
    var gridStatCombo = (RadComboBox)AccountGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0].FindControl("gridStatCombo");
    var gridStatDateCombo = (RadComboBox)AccountGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0].FindControl("gridStatDateCombo");
    var gridStatBtn = (RadButton)AccountGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0].FindControl("gridStatBtn");
    foreach (var fieldName in Configuration[Vars.StatisticalReportFields].Value
        .Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries).OrderBy(f => f.Trim()))
    {
        if (!User.ParentCawClient.HasAccountField(fieldName)) continue;
        var field = User.ParentCawClient.GetAccountField(fieldName);
        gridStatCombo.Items.Add(new RadComboBoxItem(field.DisplayName, field.ColumnName));
        if (SqlServerUtils.IsDateTimeSqlType(field.SqlDbType))
            JsDateTimeFields += field.DisplayName + "|";
    }
    if (gridStatCombo.Items.Count > 1)
    {
        gridStatCombo.Visible = true;
        gridStatDateCombo.Visible = true;
        gridStatBtn.Visible = true;
    }
}

This process works great on the initial load of the control.  However, after making any form of Ajax call (sorting, paging, grouping, etc.) the combo box in the command item template is not updated.  The content disappears.  Stepping through the code, I can see that it is executed, but the control does not appear to be updated.  The rest of the grid is updated via the Ajax call though.

What am I missing?
Tom Rasmussen
Top achievements
Rank 1
 answered on 06 Aug 2012
1 answer
74 views
I have created a RadWindow/RadGrid combination that displays the RadWindow when a row on the grid is doubled clicked. I have javascript methods in both the RadWindow asp page and the grid's page (see code below) now when the window closes I need the NeedDataSource event to be fired when the rebind in the javascript is executed. I don't think that I am wiring the event correctly or performing the process correctly. Can you provide some advise?

RadWindow page javascript:

function CloseAndRebind {
    GetRadWindow().BrowserWindow.RefreshGrid(arg);
    RadWindow().Close();
}

RadGrid page javascript:

function RefreshGrid(arg) {
    $find("<%= RaidAjaxManager1.ClientID %>").AjaxRequest("Rebind");
}

Please note that the RadGrid is the UpdateControl in the RadAjaxManager. Also, the grid does appear to have an effect of all rows being highlighted on the rebind but the NeedDataSource is never called.

Thanks,

Steve Holdorf
Steve Holdorf
Top achievements
Rank 1
 answered on 06 Aug 2012
1 answer
66 views
Hi,

I am working on a asp.net 2.0 project. We used telerik controls very heavily.

I open a popup window from another popup window, when I put cursor in any input, dropdown, date time controls, Cursor blinks slow, then it blinks very fast, after some time again slow.
This thing is keep on going. Looks like cursor is flicking or something.

Have anyone come up with this scenario?, I will really appreciate if someone could help me.

Thanks
Galin
Telerik team
 answered on 06 Aug 2012
2 answers
125 views
  • I am using MS Visual Studio 2010 in a 3.5 environment.
  • I am using Microsoft Vista (32 bit)
  • The database is currently located on an SQL 2005 server.
  • I am using RadGrid & tools, version 2012.1.411.35
  • I am using both Chrome (18.0.1025.168) and Internet Explorer (8.0.7600.16385)
  • I am programming in VB.net

I have a rad grid with three boolean fields in it.  The boolean fields show up as checkboxes.  I would like the end user to be able to click these and toggle the value WITHOUT having to click the Edit command first.

How can I do this?
Rick
Top achievements
Rank 1
 answered on 06 Aug 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
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
Iron
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?