Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
159 views
Hi;

I'm having an issue with a usercontrol I created. I've used this exact same method before atleast twice and it's always worked, but for some reason this isn't working as expected. I have a RadGrid inside the user control which contains 4 GridTemplateColumns. For some reason when I change the text in these columns the TextChanged event does not fire. Here is the code for the ascx file.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CmlDetailsGrid.ascx.cs" 
    Inherits="UserControls_CmlDetailsGrid" %> 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<link href="../Styles/Styles.css" rel="stylesheet" type="text/css" /> 
<telerik:RadAjaxManagerProxy ID="RadAjaxManager_DetailsGrid" runat="server">  
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="RadGrid_CMLDetails">  
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadGrid_CMLDetails" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManagerProxy> 
 
<script type="text/javascript">  
 
    function setFocus(caller, up, down, left, right) {  
        //alert(caller + ' ~ ' + up + ' ~ ' + down + ' ~ ' + left + ' ~ ' + right);  
        var keynum;  
        if (window.event) // IE  
        {  
            keynum = window.event.keyCode;  
        }  
        else if (e.which) // Netscape/Firefox/Opera  
        {  
            keynum = window.event.which;  
        }  
 
        if (keynum == 38 && up != "noControl") {  
 
            var control = $get(up);  
            control.focus();  
        }  
        else if (keynum == 40 && down != "noControl") {  
            var control = $get(down);  
            control.focus();  
        }  
        else if (keynum == 37 && left != "noControl") {  
 
            var control = $get(left);  
            control.focus();  
        }  
        else if (keynum == 39 && right != "noControl") {  
            var control = $get(right);  
            control.focus();  
        }  
    }  
      
</script> 
<div id="CMLDetailsGrid" style="height: 100%; width: 100%;">  
        <telerik:RadGrid ID="RadGrid_CMLDetails" runat="server" AllowSorting="True" Height="100%" 
        Width="100%" AutoGenerateColumns="False" AllowAutomaticUpdates="True" AllowFilteringByColumn="True" 
        OnPreRender="RadGrid_CMLDetails_PreRender">  
        <MasterTableView TableLayout="Fixed" EditMode="InPlace" DataKeyNames="cmlId" ItemStyle-Height="10px">  
            <HeaderStyle Wrap="false" Width="110px" HorizontalAlign="Center" /> 
            <Columns> 
                <telerik:GridBoundColumn DataField="cmlId" DataType="System.Int64" HeaderText="CML Id" 
                    SortExpression="cmlId" UniqueName="CML_ID" DataFormatString="<nobr>{0}</nobr>" 
                    Visible="false" /> 
                <telerik:GridBoundColumn DataField="partNum" DataType="System.String" HeaderText="Part #" 
                    SortExpression="partNum" UniqueName="partNum" DataFormatString="<nobr>{0}</nobr>" 
                    AutoPostBackOnFilter="true" /> 
                <telerik:GridBoundColumn DataField="cumPct" DataType="System.Int64" HeaderText="Cum%" 
                    SortExpression="cumPct" UniqueName="cumPct" DataFormatString="<nobr>{0}</nobr>" 
                    AutoPostBackOnFilter="true" /> 
                <telerik:GridBoundColumn DataField="extCost" DataType="System.Int64" HeaderText="Ext Cost" 
                    SortExpression="extCost" UniqueName="extCost" DataFormatString="<nobr>{0}</nobr>" 
                    AutoPostBackOnFilter="true" /> 
                <telerik:GridBoundColumn DataField="totalQty" DataType="System.Int64" HeaderText="Total Qty" 
                    SortExpression="totalQty" UniqueName="totalQty" DataFormatString="<nobr>{0}</nobr>" 
                    AutoPostBackOnFilter="true" /> 
                <telerik:GridBoundColumn DataField="moe" DataType="System.String" HeaderText="MOE" 
                    SortExpression="moe" UniqueName="moe" DataFormatString="<nobr>{0}</nobr>" /> 
                <telerik:GridBoundColumn DataField="source" DataType="System.String" HeaderText="Source" 
                    SortExpression="source" UniqueName="source" DataFormatString="<nobr>{0}</nobr>" /> 
                <telerik:GridBoundColumn DataField="structureQty" DataType="System.Int64" HeaderText="Part Req Qty" 
                    SortExpression="structureQty" UniqueName="structureQty" DataFormatString="<nobr>{0}</nobr>" /> 
                <telerik:GridBoundColumn DataField="unitPrice" DataType="System.Int64" HeaderText="Unit Price" 
                    SortExpression="unitPrice" UniqueName="unitPrice" DataFormatString="<nobr>{0}</nobr>" /> 
                <telerik:GridBoundColumn DataField="nre" DataType="System.Int64" HeaderText="NRE" 
                    SortExpression="nre" UniqueName="nre" DataFormatString="<nobr>{0}</nobr>" /> 
                <telerik:GridBoundColumn DataField="nreDesc" DataType="System.String" HeaderText="NRE Desc" 
                    SortExpression="nreDesc" UniqueName="nreDesc" DataFormatString="<nobr>{0}</nobr>" /> 
                <telerik:GridTemplateColumn DataField="arQty" DataType="System.Int64"   
                    HeaderText="AR Qty" SortExpression="arQty" UniqueName="gtcArQty">  
                    <ItemTemplate> 
                        <asp:TextBox runat="server" ID="txtArQty" Text='<%# DataBinder.Eval(Container.DataItem,"arQty") %>' 
                            AutoPostBack="true" OnTextChanged="CmlGridFieldsTextChanged" /> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn DataField="minBuyQty" DataType="System.Int64"   
                    HeaderText="MB Qty" SortExpression="minBuyQty" UniqueName="minBuyQty">  
                    <ItemTemplate> 
                        <asp:TextBox runat="server" ID="txtMinBuyQty" Text='<%# DataBinder.Eval(Container.DataItem,"minBuyQty") %>' 
                            AutoPostBack="true" OnTextChanged="CmlGridFieldsTextChanged" /> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn DataField="shrinkagePct" DataType="System.Int64"   
                    HeaderText="Shrk %" SortExpression="shrinkagePct" UniqueName="shrinkagePct">  
                    <ItemTemplate> 
                        <asp:TextBox runat="server" ID="txtShrinkagePct" Text='<%# DataBinder.Eval(Container.DataItem,"shrinkagePct") %>' 
                            AutoPostBack="true" OnTextChanged="CmlGridFieldsTextChanged" /> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn>                  
                <telerik:GridBoundColumn DataField="shrinkageQty" DataType="System.Int64" HeaderText="Shrk Qty" 
                    SortExpression="shrinkageQty" UniqueName="shrinkageQty" DataFormatString="<nobr>{0}</nobr>" /> 
                <telerik:GridTemplateColumn DataField="ssAsInd" DataType="System.Int64"   
                    HeaderText="SS/AS" SortExpression="ssAsInd" UniqueName="ssAsInd">  
                    <ItemTemplate> 
                        <asp:TextBox runat="server" ID="txtSsAsInd" Text='<%# DataBinder.Eval(Container.DataItem,"ssAsInd") %>' 
                            AutoPostBack="true" OnTextChanged="CmlGridFieldsTextChanged" /> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn>                          
                <telerik:GridBoundColumn DataField="expDate" DataType="System.String" HeaderText="Exp Date" 
                    SortExpression="expDate" UniqueName="expDate" DataFormatString="<nobr>{0}</nobr>" /> 
                <telerik:GridBoundColumn DataField="suplExpDate" DataType="System.String" HeaderText="Sup Exp Date" 
                    SortExpression="suplExpDate" UniqueName="suplExpDate" DataFormatString="<nobr>{0}</nobr>" /> 
                <telerik:GridBoundColumn DataField="qteOrdType" DataType="System.String" HeaderText="Quote /Order Type" 
                    SortExpression="qteOrdType" UniqueName="qteOrdType" DataFormatString="<nobr>{0}</nobr>" /> 
                <telerik:GridBoundColumn DataField="priceRecQty" DataType="System.Int64" HeaderText="Price Rec Qty" 
                    SortExpression="priceRecQty" UniqueName="priceRecQty" DataFormatString="<nobr>{0}</nobr>" /> 
                <telerik:GridBoundColumn DataField="frzInd" DataType="System.Int64" HeaderText="FRZ" 
                    SortExpression="frzInd" UniqueName="frzInd" DataFormatString="<nobr>{0}</nobr>" /> 
            </Columns> 
            <NoRecordsTemplate> 
                <div> 
                    There are no records to display.</div> 
            </NoRecordsTemplate> 
        </MasterTableView> 
        <GroupingSettings CaseSensitive="false" /> 
        <ClientSettings AllowRowsDragDrop="false" AllowKeyboardNavigation="true">  
            <Selecting AllowRowSelect="True" EnableDragToSelectRows="True" /> 
            <Scrolling AllowScroll="true" UseStaticHeaders="true" FrozenColumnsCount="1" SaveScrollPosition="true" /> 
            <Resizing AllowColumnResize="true" ClipCellContentOnResize="true" /> 
        </ClientSettings> 
    </telerik:RadGrid> 
</div> 
 

Here is the codebehind information.

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using Harris.Common.ModelStateWrapper_ASPNET;  
using Harris.Project.Mammoth.Domain;  
using Harris.Project.Mammoth.ServiceManager;  
using Telerik.Web.UI;  
 
public partial class UserControls_CmlDetailsGrid : System.Web.UI.UserControl  
{  
    Common _common;  
    private CmlDetailsService _cmldSvc;  
    ModelStateWrapper _modelStateWrapper;  
 
    /// <summary>  
    /// Handles Page_Load event of CMLDetailsGrid control.  
    /// </summary>  
    /// <param name="sender"></param>  
    /// <param name="e"></param>  
    protected void Page_Load(object sender, EventArgs e)  
    {  
 
    }  
 
    /// <summary>  
    /// Fills the CML Details grid from the database..  
    /// </summary>  
    /// <param name="cmlId">cmlId of type long</param>  
    public void FilterCmlDetailsData(long cmlId)  
    {  
 
        if (_common == null) _common = new Common(Session, Request);  
        if (_modelStateWrapper == null) _modelStateWrapper = new ModelStateWrapper(_common.GetDictionary());  
        if (_cmldSvc == null) _cmldSvc = new CmlDetailsService(_modelStateWrapper);  
 
        RadGrid_CMLDetails.DataSource = _cmldSvc.GetCmlDetailsByCmlId(cmlId);  
        RadGrid_CMLDetails.Rebind();  
        CmlDetails_SetToolTip();  
 
    }
    #region Tooltip creation for textboxes to enable excel like grid.  
 
    /// <summary>  
    /// Prerender call to add javascript which allows tabbing through textboxes in grid.  
    /// </summary>  
    /// <param name="sender"></param>  
    /// <param name="e"></param>  
    protected void RadGrid_CMLDetails_PreRender(object sender, EventArgs e)  
    {  
        CmlDetails_SetToolTip();  
    }  
 
    /// <summary>  
    /// Returns a string used to dynamically assign the javascript for excel like movement in grid.  
    /// </summary>  
    /// <param name="self">textbox making the call.</param>  
    /// <param name="leftBox">textbox to the left of caller, "noControl" if none.</param>  
    /// <param name="rightBox">textbox to the right of caller, "noControl" if none.</param>  
    /// <param name="dataItem">current dataitem from grid.</param>  
    /// <param name="location">either top or bottom, used to determine if this is the first or last item ingrid.</param>  
    /// <returns>strSelf + "','" + strUp + "','" + strDown + "','" + strLeft + "','" + strRight;</returns>  
    private string GetTexboxAttributes(string self, string leftBox, string rightBox, GridDataItem dataItem, string location)  
    {  
 
        // Cast self as textbox since it will always have something in it.  
        TextBox txtSelf = RadGrid_CMLDetails.MasterTableView.Items[dataItem.ItemIndex].FindControl(self) as TextBox;  
        string strSelf = txtSelf.ClientID;  
 
        // Get what should be above.  
        string strUp = string.Empty;  
        if (location != "top")  
        {  
            TextBox txtUp = RadGrid_CMLDetails.MasterTableView.Items[dataItem.ItemIndex - 1].FindControl(self) as TextBox;  
            strUp = txtUp.ClientID;  
        }  
        else 
        {  
            strUp = "noControl";  
        }  
 
        // Get what should be below.  
        string strDown = string.Empty;  
        if (location != "bottom")  
        {  
            TextBox txtDown = RadGrid_CMLDetails.MasterTableView.Items[dataItem.ItemIndex + 1].FindControl(self) as TextBox;  
            strDown = txtDown.ClientID;  
        }  
        else 
        {  
            strDown = "noControl";  
        }  
 
        // Need a string for the left box in grid.  
        string strLeft = string.Empty;  
        if (leftBox == "noControl")  
        {  
            strLeft = "noControl";  
        }  
        else 
        {  
            TextBox txtLeft = RadGrid_CMLDetails.MasterTableView.Items[dataItem.ItemIndex].FindControl(leftBox) as TextBox;  
            strLeft = txtLeft.ClientID;  
        }  
 
        // Need a string for the right box in grid.  
        string strRight = string.Empty;  
        if (rightBox == "noControl")  
        {  
            strRight = "noControl";  
        }  
        else 
        {  
            TextBox txtRight = RadGrid_CMLDetails.MasterTableView.Items[dataItem.ItemIndex].FindControl(rightBox) as TextBox;  
            strRight = txtRight.ClientID;  
        }  
 
        string strAttributes = strSelf + "','" + strUp + "','" + strDown + "','" + strLeft + "','" + strRight;  
 
        return strAttributes;  
    }  
 
    /// <summary>  
    /// Called by preRender to set tool tips on each textbox in grid.  
    /// </summary>  
    private void CmlDetails_SetToolTip()  
    {  
        int itemsInGrid = RadGrid_CMLDetails.Items.Count;  
        foreach (GridDataItem dataItem in RadGrid_CMLDetails.Items)  
        {  
 
            var txtArQty = (dataItem.FindControl("txtArQty"as TextBox);  
            var txtMinBuyQty = (dataItem.FindControl("txtMinBuyQty"as TextBox);  
            var txtShrinkagePct = (dataItem.FindControl("txtShrinkagePct"as TextBox);  
            var txtSsAsInd = (dataItem.FindControl("txtSsAsInd"as TextBox);  
            //  
 
            var rowToolTip = string.Empty;  
 
            // Need to get the StructureID from the hidden gridfield  
            // so I attached it to the tooltip part of the textbox.  
            for (int ix = 0; ix < dataItem.Cells.Count; ix++)  
            {  
                if (dataItem.Cells[ix].Text != "&nbsp;")  
                {  
                    rowToolTip = dataItem.Cells[ix].Text;  
                    break;  
                }  
            }  
 
            // Set tooltips for all four textboxes.  
            txtArQty.ToolTip = rowToolTip;  
            txtMinBuyQty.ToolTip = rowToolTip;  
            txtShrinkagePct.ToolTip = rowToolTip;  
            txtSsAsInd.ToolTip = rowToolTip;  
 
            // string self, string leftBox, string rightBox, GridDataItem dataItem, string location  
            // Top row in grid.  
            if (dataItem.ItemIndex == 0)  
            {  
                // Get locations for first box left to right.  
                string strArQtyAttributes = GetTexboxAttributes(txtArQty.ID, "noControl", txtMinBuyQty.ID, dataItem, "top");  
                txtArQty.Attributes.Add("onkeydown""setFocus('" + strArQtyAttributes + "');");  
 
                // Get locations for second box left to right.  
                string strMinBuyQtyAttributes = GetTexboxAttributes(txtMinBuyQty.ID, txtArQty.ID, txtShrinkagePct.ID, dataItem, "top");  
                txtMinBuyQty.Attributes.Add("onkeydown""setFocus('" + strMinBuyQtyAttributes + "');");  
 
                // Get locations for third box left to right.  
                string strShrinkagePctAttributes = GetTexboxAttributes(txtShrinkagePct.ID, txtMinBuyQty.ID, txtSsAsInd.ID, dataItem, "top");  
                txtShrinkagePct.Attributes.Add("onkeydown""setFocus('" + strShrinkagePctAttributes + "');");  
 
                // Get locations for third box left to right.  
                string strSsAsIndAttributes = GetTexboxAttributes(txtSsAsInd.ID, txtShrinkagePct.ID, "noControl", dataItem, "top");  
                txtSsAsInd.Attributes.Add("onkeydown""setFocus('" + strSsAsIndAttributes + "');");  
            }  
            // Used to handle middle rows in grid.  
            else if (dataItem.ItemIndex > 0 && dataItem.ItemIndex < RadGrid_CMLDetails.MasterTableView.Items.Count - 1)  
            {  
                // Get locations for first box left to right.  
                string strArQtyAttributes = GetTexboxAttributes(txtArQty.ID, "noControl", txtMinBuyQty.ID, dataItem, "mid");  
                txtArQty.Attributes.Add("onkeydown""setFocus('" + strArQtyAttributes + "');");  
 
                // Get locations for second box left to right.  
                string strMinBuyQtyAttributes = GetTexboxAttributes(txtMinBuyQty.ID, txtArQty.ID, txtShrinkagePct.ID, dataItem, "mid");  
                txtMinBuyQty.Attributes.Add("onkeydown""setFocus('" + strMinBuyQtyAttributes + "');");  
 
                // Get locations for third box left to right.  
                string strShrinkagePctAttributes = GetTexboxAttributes(txtShrinkagePct.ID, txtMinBuyQty.ID, txtSsAsInd.ID, dataItem, "mid");  
                txtShrinkagePct.Attributes.Add("onkeydown""setFocus('" + strShrinkagePctAttributes + "');");  
 
                // Get locations for third box left to right.  
                string strSsAsIndAttributes = GetTexboxAttributes(txtSsAsInd.ID, txtShrinkagePct.ID, "noControl", dataItem, "mid");  
                txtSsAsInd.Attributes.Add("onkeydown""setFocus('" + strSsAsIndAttributes + "');");  
            }  
            else if (dataItem.ItemIndex == RadGrid_CMLDetails.MasterTableView.Items.Count - 1)  
            {  
                // Get locations for first box left to right.  
                string strArQtyAttributes = GetTexboxAttributes(txtArQty.ID, "noControl", txtMinBuyQty.ID, dataItem, "bottom");  
                txtArQty.Attributes.Add("onkeydown""setFocus('" + strArQtyAttributes + "');");  
 
                // Get locations for second box left to right.  
                string strMinBuyQtyAttributes = GetTexboxAttributes(txtMinBuyQty.ID, txtArQty.ID, txtShrinkagePct.ID, dataItem, "bottom");  
                txtMinBuyQty.Attributes.Add("onkeydown""setFocus('" + strMinBuyQtyAttributes + "');");  
 
                // Get locations for third box left to right.  
                string strShrinkagePctAttributes = GetTexboxAttributes(txtShrinkagePct.ID, txtMinBuyQty.ID, txtSsAsInd.ID, dataItem, "bottom");  
                txtShrinkagePct.Attributes.Add("onkeydown""setFocus('" + strShrinkagePctAttributes + "');");  
 
                // Get locations for third box left to right.  
                string strSsAsIndAttributes = GetTexboxAttributes(txtSsAsInd.ID, txtShrinkagePct.ID, "noControl", dataItem, "bottom");  
                txtSsAsInd.Attributes.Add("onkeydown""setFocus('" + strSsAsIndAttributes + "');");  
            }  
 
        }  
    }
    #endregion  
 
    /// <summary>  
    /// Handles textchange event updates the quantity of the structure, and updates the tree.  
    /// This is used by both the WhereUsed grid and the ChildGrid.  
    /// </summary>  
    /// <param name="sender"></param>  
    /// <param name="e"></param>  
    protected void CmlGridFieldsTextChanged(object sender, EventArgs e)  
    {  
 
        TextBox txtChangeQuantity = ((TextBox)sender);  
        Int32 newQuantity = Int32.Parse(txtChangeQuantity.Text);  
        long structureId = long.Parse(txtChangeQuantity.ToolTip);  
 
        // get the structure record from the database  
        //var structureToUpdate = _structSvc.GetStructure(structureId);  
 
        //if (structureToUpdate != null)  
        //{  
        //    structureToUpdate.Qty = newQuantity;  
        //    var modStructure = _structSvc.EditStructure(structureToUpdate, _userName);  
 
        //    if (modStructure != null)  
        //    {  
        //        // Update tree with new quantity.  
        //        RadTreeView myStructureView = (RadTreeView)Parent.FindControl("StructureView");  
 
        //        _cgtree.ProcessTreeInstructions(_structSvc.TreeInstructions, myStructureView);  
        //    }  
        //    else  
        //    {  
        //        _modelStateWrapper.AddError("Structure Error", "Error updating structure data {" + structureId + "}");  
 
        //    }  
        //}  
    }  
}  
 

I've placed a break point in the CmlGridFieldsTextChanged event but it never reaches that point when the boxes are changed.

I've also tried several different RadAjaxManagerProxy settings but no luck. What I have above is almost identical to two other controls I've written, which both trip the text changed event without any problem.
<telerik:RadAjaxManagerProxy ID="RadAjaxManager_DetailsGrid" runat="server">  
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="RadGrid_CMLDetails">  
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadGrid_CMLDetails" /> 
                <telerik:AjaxUpdatedControl ControlID="txtArQty" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="txtArQty">  
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="txtArQty" /> 
                <telerik:AjaxUpdatedControl ControlID="RadGrid_CMLDetails" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManagerProxy> 
Iana Tsolova
Telerik team
 answered on 04 Jan 2010
1 answer
91 views

Good day!

I'm trying to delete records from a grid via javascript (__doPostBack() method). For the __doPostBack(), I'm passing in the client ID of a RadMenu. I'm able to successfully delete records from the grid, and it refreshes ok. But if I add the RadMenu to my
AjaxSetting and the Grid as the AjaxUpdatedControl, the grid doesn't refresh anymore eventhough the loading panel appears.
Why is this so?

Thank you very much.

Pavlina
Telerik team
 answered on 04 Jan 2010
1 answer
113 views
I have a grid that allows the user to add a new row to the list of objects that is saved in view state.  The new row is added correctly, I can see them and they are populated.  When the user clicks the save button, I have a method to get loop through all the rows in the grid and save the values off to an object, everything works fine EXCEPT when I try to find the controls on my dynamically added row, it can't find any of them...Am I missing something.

So to summarize:
User clicks button - add a new object to the list of objects in viewstate, set the datasource = new list of objects
User enters data and clicks the "save question" button - Loop through all of the form data and the grid and collect values to save to object.  This is where I get the error because it can't seem to find the controls on my dynamic row.  I have attached the necessary code.

 

<telerik:RadGrid ID="RadGrid1" runat="server" PageSize="10" Skin="Default" GridLines="None" 
                                        AllowSorting="True" AllowMultiRowSelection="False" AllowPaging="True" AllowMultiRowEdit="true" 
                                        ShowGroupPanel="True" GroupingEnabled="False" EnableLinqExpressions="false"   
                                        BorderWidth="1px" BorderColor="Gainsboro" 
                                        OnPreRender="RadGrid1_PreRender" OnNeedDataSource="RadGrid1_NeedDataSource"   
                                        OnItemCommand="RadGrid1_ItemCommand" OnItemDataBound="RadGrid1_ItemDataBound"   
                                        OnInsertCommand="RagGrid1_InsertCommand" 
                                    > 
                                        <PagerStyle Mode="NextPrevNumericAndAdvanced" CssClass="tbl"></PagerStyle> 
                                        <ClientSettings ReorderColumnsOnClient="false" AllowDragToGroup="true" AllowColumnsReorder="false">  
                                            <Selecting AllowRowSelect="True"></Selecting> 
                                            <ClientEvents OnRowDblClick="RowDblClick" /> 
                                            <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="False" 
                                                ScrollHeight="250" /> 
                                        </ClientSettings> 
                                          
                                        <MasterTableView DataKeyNames="FileChecklistReferenceId" EditMode="InPlace" TableLayout="Fixed" AllowFilteringByColumn="true" AutoGenerateColumns="false" CommandItemDisplay="Top">  
                                            <EditItemStyle Font-Bold="true"/>  
                                            <Columns> 
                                                <telerik:GridTemplateColumn UniqueName="Checklist" HeaderText="Checklist">  
                                                    <ItemTemplate> 
                                                        <%#Eval("FileType")%> 
                                                    </ItemTemplate> 
                                                    <EditItemTemplate> 
                                                        <asp:DropDownList ID="ddlFileType" runat="server" CssClass="ddl" /> 
                                                        <asp:RequiredFieldValidator ID="rfvFileType" runat="server" ControlToValidate="ddlFileType" Text="*" ErrorMessage="Please Select a Checklist" SetFocusOnError="True" InitialValue="-1" ValidationGroup="SaveGroup" /> 
                                                    </EditItemTemplate> 
                                                </telerik:GridTemplateColumn> 
                                                <telerik:GridBoundColumn DataField="Reference" HeaderText="Reference" ItemStyle-Font-Bold="true" /> 
                                                <telerik:GridNumericColumn UniqueName="Threshold" ConvertEmptyStringToNull="true" DataType="System.Double" HeaderText="Threshold" NumericType="Currency" DataField="Threshold" /> 
                                                <%--<telerik:GridEditCommandColumn HeaderStyle-Width="80px"  />--%> 
                                            </Columns> 
                                        </MasterTableView> 
                                    </telerik:RadGrid> 

Code to add new row:
        protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)  
        {  
            if (e.CommandName == RadGrid.InitInsertCommandName)  
            {  
                //Get the filechecklist from Viewstate  
                List<FileChecklist> fileList = (List<FileChecklist>)ViewState["Checklists"];  
                //Add a new file checklist object to it  
                fileList.Add(new FileChecklist());  
                //Save it back to ViewState  
                ViewState["Checklists"] = fileList;  
 
                e.Canceled = true;  
                System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary();  
                //the values set here must match the values types declared in the class (Model) otherwise, an exception will be thrown  
                //if any of the values do not "match" you will get a "Specified cast is not valid." exception  
                newValues["FileTypeId"] = -1;  
                newValues["FileChecklistReferenceId"] = -1;  
                newValues["Threshold"] = 0.0;  
 
                //Insert the item and rebind  
                e.Item.OwnerTableView.InsertItem(newValues);  
            }  
        } 

Data Source:
        protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)  
        {  
            RadGrid rg = (RadGrid)sender;  
 
            List<FileChecklist> fileList = (List<FileChecklist>)ViewState["Checklists"];  
            rg.DataSource = fileList;  
        } 

Code to get grid row values
        private void SaveFileChecklists(ref Question data)  
        {  
            List<FileChecklist> newList = new List<FileChecklist>();  
 
            foreach (GridDataItem row in RadGrid1.MasterTableView.Items)  
            {  
                int id = Convert.ToInt32(row.OwnerTableView.DataKeyValues[row.ItemIndex]["FileChecklistReferenceId"]);  
 
                FileChecklist fc = new FileChecklist();  
                DropDownList ddl = (row.FindControl("ddlFileType"as DropDownList); //null  
                TextBox tb = (row["Reference"].Controls[0] as TextBox); //throws index out of range error  
                RadNumericTextBox rtb = (row["Threshold"].Controls[0] as RadNumericTextBox);//throws index out of range error  
            }  
            data.FileChecklists = newList;  
        } 

WHAT AM I MISSING???

Mira
Telerik team
 answered on 04 Jan 2010
3 answers
194 views
Hi, we are using Q3 FileExplorer & .net 2 framework on a Windows 2003 server. We have the view, upload, delete paths set correctly, but the upload button is inactive. On the server, the security settings the Asp.net machine account, the Network and Network Service accounts have FULL CONTROL permissions applied at the root level of the site, with 'Allow inheritable permissions' Checked. I have verified that the sub folders where we are trying to upload files indeed have these permissions set as well. Does anyone know what would cause this and what I should do to get this working. I am puzzled as we have other sites on the same box configured the same way, and the file Explorer works fine (except those use Q2 Telerik rather than Q3 but I dont think this is the issue). Thanks in advance for any help on this.
Fiko
Telerik team
 answered on 04 Jan 2010
2 answers
181 views
I have a situation where one column can have either dollar amounts or plain decimal amounts (these are used as multipliers) and I need to change the DataFormatString for the cell based on the value of another cell in the row. 

We are binding the grid in the OnNeedDataSource event to a IList<>.  I've looked at the ItemDataBound event walk throughs but I can't seem to figure out how to access the DataFormatString.

How can I do this?

Thanks
Curtis


Curtis Hunter
Top achievements
Rank 1
 answered on 04 Jan 2010
1 answer
153 views
Is there a way to enter a Skype link?

<a href="skype:[Skype username]?call">Call me on Skype</a>

Does not work. It is just removed from the html-editore mode.

This is the way Skype suggest you put a button in your webb page:
<a href="skype:[Skype username]?call"><img src="http://download.skype.com/share/skypebuttons/buttons/call_blue_transparent_70x23.png" style="border: none;" width="70" height="23" alt="Skype Meâ„¢!" /></a>

Looking for a solution for this!

///Kris
Dobromir
Telerik team
 answered on 04 Jan 2010
7 answers
446 views
Is there a way to keep the width set on a button when using the FormDecorator?  I set the width on the button but when the button is rendered it shrinks the width to fit the text on the button.

I tried setting the CssClass on the button but it looks like the class is not carried through.

Through FireBug I can set the width on the generated <a> tag that is associated with the input button but I'm not seeing how to pass through any css attributes.
Martin
Telerik team
 answered on 04 Jan 2010
3 answers
230 views
I'm new to Telerik, and I'm trying to implement some grid functionality that I used to get when using an Infragistics grid.  Basically, I could navigate the individual cells of a grid using the up/down/left/right arrow keys.  It didn't matter if the cells were in the same row or a different row, as they long as they are adjoined.  Additionally, once navigated to, the cell becomes editable and I can update the value without having to take any additional steps, such as pressing an edit button, enter key, etc.  This is how people normally use Excel.  Once the user  leaves the row, an event is triggered which updates the record in the database with any changes without the user having to click a Save button.
In trying to mimick this behavior in RadGrid, I set the AllowKeyboardNavigation property to True, but it only allows me to use the up/down arrrows...and the entire record is selected, not an individual cell.  I want the individual cell to be selected, not the whole row.
How can I achieve TRUE Excel-like navigation using RadGrid? 
I'm using VS2008 and RadControls for ASP.NET AJAX - Latest Version: 2009.3 1103 (Nov 3, 2009).  I've downloaded a sample app from the forum, which is supposed to show how to implement this functionality, but apparently it is somewhat old and seems to have compile problems as my version of VS and the RadConrols are newer.
Princy
Top achievements
Rank 2
 answered on 04 Jan 2010
1 answer
288 views
I would like to filter out unwanted file types in the RadUpload control. This is not the same as the AllowedFileExtensions property as this is for validating, not displaying with the "SELECT" button. When the "SELECT" button is clicked, I want to only display files that are of the type I want filtered (such as .doc or .jpg, etc.) I have researched this for awhile now and cannot find any information on how to do this. Any help would be greatly appreciated.
Genady Sergeev
Telerik team
 answered on 04 Jan 2010
3 answers
236 views
I am using the example from here to implement filtering of a column using DateTime field. I have the following dataformatstring for my gridbound column

<telerik:GridBoundColumn DataField="Date" HeaderText="Date" UniqueName="Date" DataFormatString="{0:MM/dd/yyyy hh:mm:ss}" > 

If I use the scriptblock from the example,the toDate for the filter does not include the time portion and it defaults to 12:00 AM and so, it behave like the filter is exclusive of the To date. How do I make it inclusive, so that the filtered data includes the date selected in the ToDate datepicker?

Thanks in advance,
Saritha
Veli
Telerik team
 answered on 04 Jan 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?