Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
399 views
Folks using VStudio 2010 with UI for ASP.NET AJAX Q2 2014 SP1.
I have 3 RadNumericText Boxes (txtRadOriginalPages, txtRadCopies and txtRadCopyQty1) in a Form.
Basically it does do Client Side Total based on txtRadOriginalPages &  txtRadCopies  and populate txtRadCopyQty1. 
I would like to Populate txtRadCopies with 0.00 if it is null and populate the Total txtRadCopyQty1 from the Value of txtRadOriginalPages in Client Side.
Below is my complete Code Description and attached is my desired result. 

Thanks for any help.

gc_0620

<%@ Page Language="C#" %>
 
<%@ Import Namespace="System.Data" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<script runat="server">
 
  
 
    protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
 
        DataTable dt = new DataTable();
 
        DataRow dr;
 
        int colsNum = 4;
 
        int rowsNum = 5;
 
        string colName = "Column";
 
 
 
        for (int j = 1; j <= colsNum; j++)
        {
 
            dt.Columns.Add(String.Format("{0}{1}", colName, j));
 
        }
 
 
 
        for (int i = 1; i <= rowsNum; i++)
        {
 
            dr = dt.NewRow();
 
 
 
            for (int k = 1; k <= colsNum; k++)
            {
 
                dr[String.Format("{0}{1}", colName, k)] = String.Format("{0}{1} Row{2}", colName, k, i);
 
            }
 
            dt.Rows.Add(dr);
 
        }
 
 
 
        (sender as RadGrid).DataSource = dt;
 
    }
 
      
 
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head id="Head1" runat="server">
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <title>RadControls</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Transparency="50"
        BackColor="Yellow" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateEditColumn="true" OnNeedDataSource="RadGrid_NeedDataSource">
        <MasterTableView EditMode="EditForms">
            <EditFormSettings EditFormType="Template" />
            <EditFormSettings>
                <FormTemplate>
                    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                        <script type="text/javascript">
 
 
 
                            //Calculate the original pages * the copies and input the result to copy quantity 
 
                            var ActualIndex;
 
                            var index;
 
                            var txtRadOriginalPages = null;
 
                            var txtRadCopies = null;
 
                            var txtRadCopyQty1 = null;
 
 
 
                            function updateTotals(sender, args) {
 
                                var v1 = txtOriginalPages.get_value();
 
                                var v2 = txtCopies.get_value();
 
                                var finalValue = parseFloat(v1) + parseFloat(v2);
 
                                txtRadCopyQty1.set_value(parseFloat(finalValue));
 
                            }
 
                            function setIndex(sender, args) {
 
                                index = args.get_itemIndexHierarchical();
 
                            }
 
                            function setActualIndex() {
 
                                ActualIndex = index;
 
                            }
 
                            function Load1(sender, args) {
 
                                txtOriginalPages = sender;
 
                            }
 
                            function Load2(sender, args) {
 
                                txtCopies = sender;
 
                            }
 
                            function Load3(sender, args) {
 
                                txtRadCopyQty1 = sender;
 
                            }
 
  
 
                        </script>
                    </telerik:RadScriptBlock>
                    <table>
                        <tr>
                            <td align="left">
                                <asp:Label ID="lblOriginalPages" runat="server" Text="Original Pages:"></asp:Label>
                            </td>
                            <td align="left">
                                <telerik:RadNumericTextBox ID="txtRadOriginalPages" runat="server" NumberFormat-DecimalDigits="2"
                                    NumberFormat-DecimalSeparator="." NumberFormat-GroupSeparator="," NumberFormat-GroupSizes="3"
                                    NumberFormat-AllowRounding="true" Type="Number">
                                    <ClientEvents OnValueChanged="updateTotals" OnFocus="setActualIndex" OnLoad="Load1" />
                                </telerik:RadNumericTextBox>
                            </td>
                            <td align="left">
                                <asp:Label ID="lblCopies" runat="server" Text="Copies:"></asp:Label>
                            </td>
                            <td align="left">
                                <telerik:RadNumericTextBox ID="txtRadCopies" runat="server" NumberFormat-DecimalDigits="2"
                                    NumberFormat-DecimalSeparator="." NumberFormat-GroupSeparator="," NumberFormat-GroupSizes="3"
                                    NumberFormat-AllowRounding="true" Type="Number">
                                    <ClientEvents OnValueChanged="updateTotals" OnFocus="setActualIndex" OnLoad="Load2" />
                                </telerik:RadNumericTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td align="left">
                                <asp:Label ID="lblCopyQty1" runat="server" Text="Original Pages + Copy:"></asp:Label>
                            </td>
                            <td align="left">
                                <telerik:RadNumericTextBox ID="txtRadCopyQty1" runat="server" NumberFormat-DecimalDigits="2"
                                    NumberFormat-DecimalSeparator="." NumberFormat-GroupSeparator="," NumberFormat-GroupSizes="3"
                                    NumberFormat-AllowRounding="true" Type="Number">
                                    <ClientEvents OnLoad="Load3" />
                                </telerik:RadNumericTextBox>
                            </td>
                            <td align="left">
                                <asp:Label ID="lblInkType1" runat="server" Text="Ink Type 1:"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" colspan="6">
                                <asp:ImageButton ID="ImageButtonDemoMainUpdateInsert" ToolTip='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                    CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'
                                    runat="server" ImageUrl="~/Images/GridUpdateEditInsert.gif" />
                                <asp:ImageButton ID="ImageButtonDemoMainCancelUpdateInsert" ToolTip="Cancel" CommandName="Cancel"
                                    CausesValidation="false" runat="server" ImageUrl="~/Images/GridCancelEditInsert.gif" />
                            </td>
                        </tr>
                    </table>
                </FormTemplate>
            </EditFormSettings>
        </MasterTableView>
    </telerik:RadGrid>
    </form>
</body>
</html>
 
Konstantin Dikov
Telerik team
 answered on 25 Sep 2014
1 answer
182 views
I have a pretty straight-forward RadGrid, which is bound to a LinqDataSource. 
Paging works perfectly, until i select a row in the grid.

<ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true">
    <Selecting AllowRowSelect="true"></Selecting>
</ClientSettings>

EnableViewState is on, AllowCustomPaging is set to off. 

I am getting this error:
Unhandled exception at line 1, column 123054 in http://localhost:56409/bundles/MsAjaxJs?v=D6VN0fHlwFSIWjbVzi6mZyE9Ls-4LNrSSYVGRU46XF81

0x800a139e - Laufzeitfehler in JavaScript: Sys.WebForms.PageRequestManagerServerErrorException: Der Index lag außerhalb des Bereichs. Er muss nicht negativ und kleiner als die Auflistung sein.

Parametername: index

(Translation: Index was out of range. Must be non-negative and less than the size of the collection. Parameter: Index)

Is there any solution to this? 
Again - I am DataBinding via a LinqDataSource (in markup only). There are other DataSources on the Page, which use the first DataSource in their whereparameters. Is this the Problem? 

DataSource Markup:
<asp:LinqDataSource ID="StellenLinqDS" runat="server" ContextTypeName="MySolution.DataObjects" EntityTypeName="" OrderBy="LetzteAktivitaet desc" Select="new (Name, Unternehmen, ID, Status, Anzahl, AnzahlPlaetze, LetzteAktivitaet)" TableName="StellenDaten" Where="Status != @Status">
<WhereParameters>
 <asp:Parameter DefaultValue="Archiv" Name="Status" Type="String" />
</WhereParameters>
</asp:LinqDataSource>
Thilo
Top achievements
Rank 1
 answered on 25 Sep 2014
1 answer
109 views

I'm having a little difficulty with updating a hierarchical grid.  My gird has 3 levels, orders,deliveries and schedules.  On my top level, I want to be able to directly update the grid row on a few of the columns.  I have a sample program where I do the same thing on a normal grid and it works.  Identical code in my Hierarchical grid does not.  The problem I'm having is when it come time for me to assign the grid item it's new value.  For some reason, my grid item is being determined as read-only upon assignment and is failing.  I've confirmed that the item is not read-only, but when I try to update it, it's being rendered as read-only and I don't know why.  My update routine is as follows.  Any help with this would be appreciated.  Thanks.

 protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
       
        foreach (GridColumn column in e.Item.OwnerTableView.RenderColumns)
        {
            if (column is IGridEditableColumn)
            {
                IGridEditableColumn editableCol = (column as IGridEditableColumn);
                if (editableCol.IsEditable)
                {
                    GridEditableItem editedItem = e.Item as GridEditableItem;
                    object oldval = editedItem.SavedOldValues[column.UniqueName];
                    GridEditManager editMan = editedItem.EditManager;
                    IGridColumnEditor editor = editMan.GetColumnEditor(editableCol);
                    object editorValue = null;
                    editorValue = (editor as GridTextColumnEditor).Text;
                    try
                    {
                    
                       DataRow[] changedRows = this.ItemSource.Select("ORDER = '" + editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]        ["ORDER"].ToString() + "'");
                       changedRows[0][column.UniqueName] = editorValue;           // This is the line where the error is occurring !!!
                       ItemSource.AcceptChanges();
                      
                    }  
                    catch (Exception ex)
                    {
                        Label1.Text = "<strong>Unable to set value of column '" + column.UniqueName + "'</strong> - " + ex.Message;
                        e.Canceled = true;
                        break;
                    }
                }
            }
        }

    }

Viktor Tachev
Telerik team
 answered on 25 Sep 2014
3 answers
288 views
Hello Telerik Team.

I faced with a problem about Multi-column Combobox selection.
I tried combobox binding like below.  It doesn't work fine.

Selected combobox item is not shown on the box.
I want to select located 2nd item. but still shown "System.Data.DataRowView" text

please let me know how can i  solve this problem

thanks you.
<%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="RadControlsWebApp1._Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <scripts>
            <%--Needed for JavaScript IntelliSense in VS2010--%>
            <%--For VS2008 replace RadScriptManager with ScriptManager--%>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </scripts>
    </telerik:RadScriptManager>
    <script type="text/javascript">
        //Put your JavaScript code here.
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <telerik:RadComboBox runat="server" ID="RadComboBoxProduct" TabIndex="13" Width="100%"
        HighlightTemplatedItems="true" EnableEmbeddedSkins="true" >
        <headertemplate>
                                        <ul>
                                            <li class="col1">Product </li>
                                            <li class="col2">Product Status </li>
                                        </ul>
                                    </headertemplate>
        <itemtemplate>
                                        <ul>
                                            <li class="col1">
                                                <asp:Label runat="server" ID="RadComboBoxItemProduct"></asp:Label>
                                            </li>
                                            <li class="col2">
                                                <asp:Label runat="server" ID="RadComboBoxItemProductStatus"></asp:Label>
                                            </li>
                                        </ul>
                                    </itemtemplate>
    </telerik:RadComboBox>
    </form>
</body>
</html>

Private Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Dim datatable As New DataTable()
 
        datatable.Columns.Add("ProductName")
        datatable.Columns.Add("CodeName")
        datatable.Columns.Add("FirmProductNo")
 
 
        datatable.Rows.Add("11396", "ddddd", "Inhouse")
        datatable.Rows.Add("23742", "ereeee", "Died")
        datatable.Rows.Add("2302", "oewjhf", "Dead")
        datatable.Rows.Add("0928", "ddddd", "Cutted")
 
        RadComboBoxProduct.DataSource = datatable
        RadComboBoxProduct.DataBind()
    End Sub
 
    Protected Sub RadComboBoxProduct_ItemDataBound(sender As Object, e As Telerik.Web.UI.RadComboBoxItemEventArgs) Handles RadComboBoxProduct.ItemDataBound
 
        Dim labelProduct = DirectCast(RadComboBoxProduct.Items(e.Item.Index).FindControl("RadComboBoxItemProduct"), Label)
        Dim labelProductStatus = DirectCast(RadComboBoxProduct.Items(e.Item.Index).FindControl("RadComboBoxItemProductStatus"), Label)
 
        labelProduct.Text = e.Item.DataItem("ProductName")
        labelProductStatus.Text = e.Item.DataItem("CodeName")
 
        e.Item.Value = e.Item.DataItem("FirmProductNo")
    End Sub
Aprajita
Top achievements
Rank 1
 answered on 25 Sep 2014
7 answers
247 views
hello,

I have this column in a RadGrid :
<Telerik:GridTemplateColumn DataType="System.Int32" HeaderText="Impression Papier" UniqueName="NbPapier">
 <ItemTemplate>
  <asp:CheckBox ID="ChkBoxNb" runat="server" AutoPostBack="false" OnCheckedChanged="ToggleRadNumericState"/>
  <Telerik:RadNumericTextBox ID="RadNumericTextBoxNb" runat="server" AllowOutOfRangeAutoCorrect="true"
                                                AutoPostBack="false" DataType="System.Int32" Enabled="true" MinValue="0" NumberFormat-AllowRounding="false"
                                                NumberFormat-DecimalDigits="0" ShowSpinButtons="true" Type="Number" ValidationGroup="MyValidationGroup"
                                                MaxLength="3" Value="0" />
 </ItemTemplate>
</Telerik:GridTemplateColumn>


I
need to access a CheckBox and a RadNumericTextBox that are in the same GridTemplateColumn to affect the enabled property of the  RadNumericTextBox as CheckBox.checked and take into account the change is immediate without the need of a PostBack like this code but as javascript :

protected void ToggleRadNumericState(object sender, EventArgs e)
{
        (((sender as CheckBox).NamingContainer as GridItem).FindControl("RadNumericTextBoxNb") as RadNumericTextBox).Enabled = (sender as CheckBox).Checked;
}
Why can I do it?

Thanks for your help.
Aprajita
Top achievements
Rank 1
 answered on 25 Sep 2014
7 answers
405 views
http://www.telerik.com/support/code-library/prevent-losing-batch-editing-changes-on-paging-or-any-other-postback

Where do I set to ignore the [Save changes] button that will be doing the update?    I get the same prompt that changes will be lost.
Viktor Tachev
Telerik team
 answered on 25 Sep 2014
1 answer
115 views
Hi Team,

I have a radgrid with some rows in it .When i expand the each row there are three tabs inside it.
When i click on the first tab need to display the grid(grid name:compartmentgrid) under this tab.In this grid i have 8 coloumns and some columns have no data in it.
I need to find out the which column has no data and highlight that column with yellow color.
I am writing the code in the itemdatabound event for this grid.
How to find which column has null value because it is inside another grid and also this grid is displayed once you click on the tab.

Regards,
Sudhakar.


Viktor Tachev
Telerik team
 answered on 25 Sep 2014
12 answers
1.4K+ views
How can I enable the client side sorting (single column I guess is valid here) and paging without refreshing the page.
I mean whatever the grid gets from the bound datatable, it should be able to enable sorting on the client side and paging as well depending upon what page size I specify.
I don't want to refresh my page while sorting the grid or changing the page.

Thanks
Hary
Satish
Top achievements
Rank 1
 answered on 25 Sep 2014
0 answers
220 views
Securing web applications is a serious matter and no one can be cautious enough.

Check out what you need to know and look for in the following blog post, when you are implementing security measure for your users' content. Preventing XSS attack is easy, as long as you know how they work.
Telerik Admin
Top achievements
Rank 1
Iron
 asked on 25 Sep 2014
1 answer
132 views
Morning,

On the RadNumericTextBox, I want to set MaxValue for validation BUT I do not want it to set the MaxValue automatically when a greater value is entered.  e.g. with MaxValue="6", if I enter 8, the value automatically changes to 6 on blur.  However, I want it to remain as 8 but show invalid.

How can I do this?  Do I need to use a validator control instead?


Thanks
Angel Petrov
Telerik team
 answered on 25 Sep 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?