Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
121 views
I have a problem with geting vaules form the Edit / Popup Form.
The underlying datasource is an Object.

I can Insert the values in the form, but my code gets only emtpy values.

What can be wrong

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Arbeitsprofile.aspx.cs" Inherits="Web.Stammdaten.Arbeitsprofile" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadAjaxManager ID="AjaxManager" runat="server" 
                DefaultLoadingPanelID="AjaxLoadingPanel" EnableHistory="True">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="grdArbeitsprofile">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="grdArbeitsprofile" 
                        LoadingPanelID="AjaxLoadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="AjaxLoadingPanel" runat="server" Skin="Default" 
                Transparency="70">
    </telerik:RadAjaxLoadingPanel> 
    <telerik:RadGrid ID="grdArbeitsprofile" runat="server" AllowSorting="True" 
        AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" GridLines="None" 
        Skin="Sitefinity" OnInsertCommand="grdArbeitsprofile_InsertCommand">
        <MasterTableView AutoGenerateColumns="False" EditMode="EditForms" CommandItemDisplay="Top" DataKeyNames="ID">
         <Columns>
          <telerik:GridBoundColumn
            DataField="Bezeichnung"
            HeaderText="Bezeichnung"
            SortExpression="Bezeichnung"
            UniqueName="Bezeichnung" />
          <telerik:GridBoundColumn
            DataField="Bemerkung"
            HeaderText="Bemerkung"
            SortExpression="Bemerkung"
            UniqueName="Bemerkung" />
         </Columns>
             <EditFormSettings EditFormType="AutoGenerated"  InsertCaption="Neues Arbeitsprofil" CaptionFormatString="Arbeitsprofil: {0}" CaptionDataField="Bezeichnung">                   
</EditFormSettings>
        </MasterTableView>
        <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
            <Selecting AllowRowSelect="True" />
 </ClientSettings>
     </telerik:RadGrid>   
    </asp:Content>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Pepperhost.Greifplaner.Web.Data;
using Telerik.Web.Design;
using Telerik.Web.UI;
  
  
namespace Web.Stammdaten
{
    using DTO=Pepperhost.Greifplaner.Web.Data.DataTransferobjects;
    public partial class Arbeitsprofile : System.Web.UI.Page
    {
        DataProvider db = new DataProvider();
  
        protected void Page_Load(object sender, EventArgs e)
        {
            grdArbeitsprofile.UpdateCommand+= new GridCommandEventHandler(grdArbeitsprofile_UpdateCommand);
           // grdArbeitsprofile.InsertCommand+= new GridCommandEventHandler(grdArbeitsprofile_InsertCommand);
            grdArbeitsprofile.NeedDataSource+=new GridNeedDataSourceEventHandler(grdArbeitsprofile_NeedDataSource);
              
            grdArbeitsprofile.DataSource = db.GetArbeitsprofilListe();
            grdArbeitsprofile.DataBind();
  
        }
  
        protected void grdArbeitsprofile_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.PerformInsertCommandName)
            {
                 GridEditableItem item = e.Item as GridEditableItem;  
          
                try
                {
                    DTO.Arbeitsprofil arbeitsprofil = new DTO.Arbeitsprofil();
  
                   arbeitsprofil.Bemerkung = (item["Bemerkung"].Controls[0] as TextBox).Text;
                   arbeitsprofil.Bezeichnung = (item["Bezeichnung"].Controls[0] as TextBox).Text;
                   db.CreateArbeitsprofil(arbeitsprofil);
                }
                catch (Exception ex)
                {
                    grdArbeitsprofile.Controls.Add(new LiteralControl("Unable to update Employee. Reason: " + ex.Message));
                    e.Canceled = true;
                }
  
            }
             
        }
  
        protected void grdArbeitsprofile_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
  
            try
            {
                grdArbeitsprofile.DataSource = db.GetArbeitsprofilListe();
                grdArbeitsprofile.DataBind();
            }
            catch (Exception ex)
            {
                grdArbeitsprofile.MasterTableView.NoRecordsTemplate = new NoRecordsTemplate(ex.Message);
            }
            finally
            {
                  
            }
  
        }
        protected void grdArbeitsprofile_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {  
           GridEditableItem item = e.Item as GridEditableItem;
  
           try
           {
               DTO.Arbeitsprofil arbeitsprofil = new DTO.Arbeitsprofil();
               arbeitsprofil.ID=(int)item.OwnerTableView.DataKeyValues[item.ItemIndex]["ID"];
               arbeitsprofil.Bemerkung = (item["Bemerkung"].Controls[0] as TextBox).Text;
               arbeitsprofil.Bezeichnung = (item["Bezeichnung"].Controls[0] as TextBox).Text;
               db.UpdateArbeitsprofil(arbeitsprofil);
           }
           catch (Exception ex)
           {
               grdArbeitsprofile.Controls.Add(new LiteralControl("Unable to update Employee. Reason: " + ex.Message));
               e.Canceled = true;
           }
        }
       }
    class NoRecordsTemplate : ITemplate
    {
        private string _Message;
        public NoRecordsTemplate(string Message)
        {
            _Message = Message;
        }
  
        public void InstantiateIn(Control container)
        {
            Label lbl = new Label();
            lbl.ID = "Label1";
            lbl.Text = _Message;
            lbl.ForeColor = System.Drawing.Color.RoyalBlue;
            container.Controls.Add(lbl);
        }
    }
  
}
Daniel
Telerik team
 answered on 17 Aug 2010
2 answers
97 views
Hi telerik team

i need to call custom validation function on insert- edit event of appointment.

in scheduler i used Advanced edit/insert template (Advanced Edit/Insert template). but i can't add onclientclick event on Save Linkbutton.

is there any other way to call custom function on save to which i can pass the form controls. Actually i need to check for various required field's values and i dont want to use RequiredFieldValidator in the form.

if you need any other info, please let me know.

Regards
Manmeet Singh
Manmeet
Top achievements
Rank 1
 answered on 17 Aug 2010
2 answers
100 views
I want to use the HeaderContextMenu for a RadGrid, but there are several TemplateColumns and they are being ignored by the HeaderContextMenu commands.

I am able to sort, group and filter by the normal BoundColumns, but if I try to do anything with one of the TemplateColumns it doesn't work. I added SortExpression and UniqueName to each of the templates, but still no dice.

Is there anything else I need to do to make it work?

Thanks

<telerik:RadGrid ID="rgLoads" runat="server" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" AllowFilteringByColumn="true" OnItemCommand="rgLoads_ItemCommand" EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true" OnItemDataBound="rgLoads_ItemDataBound" OnGroupsChanging="rgLoads_GroupsChanging" OnPageIndexChanged="rgLoads_PageIndexChanged">
        <HeaderContextMenu OnItemClick="HeaderContextMenu_ItemClick" />
        <GroupingSettings CaseSensitive="false" />        
        <MasterTableView IsFilterItemExpanded="false" EnableHeaderContextMenu="true" Width="100%">
            <Columns>
                <telerik:GridBoundColumn DataField="UrgHours" HeaderText="Urg Hrs" SortExpression="UrgHours" UniqueName="UrgHours" />
                <telerik:GridTemplateColumn HeaderText="LD Code" SortExpression="LoadCode" UniqueName="LoadCode">
                    <ItemTemplate>
                        <asp:HyperLink ID="LDCodeTarget" runat="server" NavigateUrl="#" Text='<%# Eval("LoadCode") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="SpotLight" HeaderText="Spotlight" SortExpression="SpotLight" UniqueName="SpotLight" />
                <telerik:GridTemplateColumn HeaderText="PRO" SortExpression="ProNo" UniqueName="ProNo">
                    <ItemTemplate>
                        <asp:HyperLink ID="ProTarget" runat="server" NavigateUrl="#" Text='<%# Eval("ProNo") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="LoadSegment" HeaderText="Load Seg" SortExpression="LoadSegment" UniqueName="LoadSegment" />
                <telerik:GridBoundColumn DataField="SendFromCity" HeaderText="Origin City" SortExpression="SendFromCity" UniqueName="SendFromCity" />
                <telerik:GridBoundColumn DataField="SendFromStateProv" HeaderText="Origin State" SortExpression="SendFromStateProv" UniqueName="SendFromStateProv" />
                <telerik:GridBoundColumn DataField="SendToCity" HeaderText="Dest City" SortExpression="SendToCity" UniqueName="SendToCity" />
                <telerik:GridBoundColumn DataField="SendToStateProv" HeaderText="Dest State" SortExpression="SendToStateProv" UniqueName="SendToStateProv" />
                <telerik:GridBoundColumn DataField="PickupDate" HeaderText="PU Dt" SortExpression="PickupDate" UniqueName="PickupDate" />
                <telerik:GridBoundColumn DataField="PickupTime" HeaderText="PU Tm" SortExpression="PickupTime" UniqueName="PickupTime" />                
                <telerik:GridBoundColumn DataField="LOH" HeaderText="LOH" SortExpression="LOH" UniqueName="LOH" />
                <telerik:GridBoundColumn DataField="MoveType" HeaderText="Move Type" SortExpression="MoveType" UniqueName="MoveType" />
                <telerik:GridBoundColumn DataField="STerm" HeaderText="STerm" SortExpression="STerm" UniqueName="STerm" />
                <telerik:GridBoundColumn DataField="DH" HeaderText="DH" SortExpression="DH" UniqueName="DH" />
                <telerik:GridTemplateColumn HeaderText="Assgn Code" SortExpression="AssignmentCode" UniqueName="AssignmentCode">
                    <ItemTemplate>
                        <asp:HyperLink ID="AssignmentCodeTarget" runat="server" NavigateUrl="#" Text='<%# Eval("AssignmentCode") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderText="Error Code" SortExpression="ErrorCode" UniqueName="ErrorCode">
                    <ItemTemplate>
                        <asp:HyperLink ID="ErrorCodeTarget" runat="server" NavigateUrl="#" Text='<%# Eval("ErrorCode") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderText="Recom" SortExpression="Recom" UniqueName="Recom">
                    <ItemTemplate>
                        <asp:Literal ID="litRecom" runat="server" Text='<%# Eval("Recom") %>' />
                        <asp:HyperLink ID="RecomTarget" runat="server" NavigateUrl="#" Text='<%# Eval("Recom") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderText="Driver Code" SortExpression="DriverCode" UniqueName="DriverCode">
                    <ItemTemplate>
                        <asp:HyperLink ID="DriverCodeTarget" runat="server" NavigateUrl="#" Text='<%# Eval("DriverCode") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="MinsOfferSent" HeaderText="Mins Offer Sent" SortExpression="MinsOfferSent" UniqueName="MinsOfferSent" />
                <telerik:GridBoundColumn DataField="HTDaysOut" HeaderText="HT Days Out" SortExpression="HTDaysOut" UniqueName="HTDaysOut" />
                <telerik:GridBoundColumn DataField="TruckSize" HeaderText="Truck Size" SortExpression="TruckSize" UniqueName="TruckSize" />
                <telerik:GridBoundColumn DataField="DIV" HeaderText="DIV" SortExpression="DIV" UniqueName="DIV" />
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
Daniel
Telerik team
 answered on 17 Aug 2010
9 answers
342 views
I have read throught he forum and see that a number of people do not like the feature of the RadDatePicker auto correcting.

To rehash:

If I enter 13/12/2010 I DO NOT want the control to automatically change it to 12/13/2010.

I have tried adding the following:

 

 

<telerik:RadScriptBlock runat="server">  
 
    <script type="text/javascript">  
 
        Telerik.Web.UI.RadDateInput.prototype.parseDate = function(value, baseDate) {  
 
            if (new Date(value) != "NaN")  
 
                return value;  
 
            }   
 
    </script>   
 
</telerik:RadScriptBlock> 
 


However, while this certainly causes the dates to no longer change it also prevents me from putting in VALID dates and prevents me from using the calendar control. I would appreciate any clarification I may be missing.

Thanks,

Chris Lynch
Top achievements
Rank 1
 answered on 17 Aug 2010
2 answers
598 views
Hi,

I am trying to capitalise the text that has been input into a RadTextBox when focus is moved out of the control.

This is my code:
<telerik:RadTextBox ID="txtPostcode" runat="server" MaxLength="8">
<ClientEvents OnBlur="this.set_value(this.get_value().toUpperCase())" />
</telerik:RadTextBox>

This throws an obscure ajax javascript error when the form is first loaded:
Microsoft JScript runtime error: Object doesn't support this property or method.
This is on line 3 at

a(

 

this,b.EventArgs.Empty)

 

of the MicrosoftAjax.js that is generated dynamically by the Telerik.Web.UI assembly. 

Can you tell me what's wrong?

Thanks.
Craig Wallace
Top achievements
Rank 1
 answered on 17 Aug 2010
2 answers
205 views
I have a column in my RadGrid whose visibility is dependant on a checkbox on the page. When the user checks the checkbox, the column appears. When they uncheck, it disappears. Both the checkbox and the grid are in an ajax panel. Works fine.

My problem is when the user sets a filter for the column in question and then unchecks the checkbox, the filter persists. It's not apparent to the user that data is being filtered because the column with the filter is no longer visible.

So I want to reset the column filter when the user toggles the visiblity of the column. To do this, I have the following code in my checkbox's CheckChanged event handler:

if(chkShowInActive.Checked)
{
    myGrid.Columns.FindByUniqueName("IsActive").Visible = true;
}
else
{
    myGrid.Columns.FindByUniqueName("IsActive").Visible = false;
}
  
myGrid.Columns.FindByUniqueName("IsActive").CurrentFilterFunction = GridKnownFunction.NoFilter;
myGrid.Rebind();

This doesn't seem to have any effect. The grid still filters the data. What am I doing wrong?
Robert
Top achievements
Rank 1
 answered on 17 Aug 2010
1 answer
101 views
I have My (user defined) columns and Delete (autogenerated) column, how to move to left side this delete column.
Shinu
Top achievements
Rank 2
 answered on 17 Aug 2010
6 answers
175 views
wanted to ask if i do set EnableLoadOnDemad, MarkFirstMatch and AllowCustomText to true, how to restrict user from entering text which is not in a display member of combobox items.
Like lets say i have India, USA and Russia as my combobox items then if i type in Spain in the combobox how to give a message to the user that this item is not present in the combobox list of items.
i would like to do this validation in the OnSlectedindexchanged event please let me know if this can be done.
this is how my combobox looks:
<telerik:RadComboBox ID="radProject" AllowCustomText="true"    AccessibilityMode="false" AutoPostBack="true" runat="server" DropDownWidth="240px" onselectedindexchanged="radProject_SelectedIndexChanged" EnableLoadOnDemand="true" MarkFirstMatch="true" Skin="Web20" Filter="Contains"
ondatabinding="radProject_DataBinding">
</telerik:RadComboBox>


any input is appreciated.
Senthil ramna
Top achievements
Rank 1
 answered on 17 Aug 2010
2 answers
468 views
Hi,

I have a RadComboBox that has its EmptyMessage property set to - Select Table -. I am trying to create a some validation where if the user does not select a Table from the RadComboBox an error message is displayed saying "Please select a table..."

//RadComboBox:

 

<telerik:RadComboBox ID="RadComboBoxTables" Runat="server"

 

 

DataSourceID="ObjectDataSourceMetaDateTables" DataTextField="Name"

 

 

DataValueField="Name" Label="Table: "

 

 

ondatabound="Tables_DataBound"

 

 

onitemsrequested="Tables_ItemsRequested"

 

 

OnClientSelectedIndexChanging="metaDataTableSelected"

 

 

LabelCssClass="riLabel" Width="100%"

 

 

EmptyMessage="- Select table - "

 

 

ValidationGroup="AttrValidationGroup">

 

 

</telerik:RadComboBox>

I tried doing  this 2 ways:

1. I used a CompareValidator..This should display the error message if the user does not select a table; however, no error message is displayed. If select -Select table - from RadComboBox again, no error is displayed.  Is/Can the EmptyMessage be used here as the value to compare to?

(NOTE: if I change the Operator to Operator=Equal, then it displays the error if user doesn't select anything, selects a table, or selects "- Select table - " from RadComboBox.)

//CompareValidator:

 

 

<asp:CompareValidator

 

 

 

 

 

ID="CompareValidatorRadComboxBoxTables"

 

 

 

 

 

runat="server"

 

 

 

 

 

ValueToCompare=" - Select table - "

 

 

 

 

 

Operator="NotEqual"

 

 

 

 

 

ControlToValidate="RadComboBoxTables"

 

 

 

 

 

ErrorMessage="Please select Table..."

 

 

ValidationGroup="AttrValidationGroup">

 

 

 

 

 

</asp:CompareValidator>

I also tried using the Requiredfield Validator like a saw in an example on this site (http://demos.telerik.com/aspnet-ajax/combobox/examples/default/defaultcs.aspx  this example worked fine), but no error was displayed for my app.

//RequiredFieldValidator:

 

 

<asp:RequiredFieldValidator ID="RequiredFieldValidatorComboTxtBxTables"

 

 

 

 

 

runat="server"

 

 

ControlToValidate="RadComboBoxTables"

 

 

 

 

 

ErrorMessage="Please select table from list..."

 

 

 

 

 

ValidationGroup="AttrValidationGroup">

 

 

</asp:RequiredFieldValidator>

 


Any advice and/or help will be appreciated.

Thanks in advance...
gary

gary
Top achievements
Rank 1
 answered on 17 Aug 2010
3 answers
541 views
I have a bar type chart and i have to display percentage format on the y axis. If i set the appearence of the y axis to percentage it is multiplying the values by 100 more and displaying the Percentage Format. This is happening in both autoscale set to true or false. Could You please suggest how can i get the actual values on y -axis for percent rather than the values which are increased by 100.

In the screenshot attched you see that the values for the chart are between 0 - 100 and if the format is specified default or number or currrency the scale is set to 0-120. But if i change it to percentage it is showing values ranging from 0-12000%. Instead i want 0 - 120 scale with % sign next to it.
Vamsi
Top achievements
Rank 1
 answered on 17 Aug 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?