Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
240 views
Hey everyone,

I have a grid,its data source is a data table.I've created columns in the data table.and at page_load grid is visible with no records in it & just names of the columns.Now,I've a button external to the grid which i am using to open up the insert Form.I've created form template for inserting values.It also have 2 buttons Save and Cancel.

Now,on Save button I put all the values inserted by the user in the first row of the data table.And it is visible in the data Table when i see using breakpoints.But My problem is that it remains in the Data Table and is not Visible in the Grid.I want Grid to show values inside the data Table and values keeps on increasing as user inserts more items to the Data Table.

My code for CS is--
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            dtValues = new DataTable();
            dtValues.Columns.Add("Items");
            dtValues.Columns.Add("Rate");
            dtValues.Columns.Add("Quantity");
            dtValues.Columns.Add("Amount");
            RadGrid1.DataSource = dtValues;
        }
protected void btnAdd_Click(object sender, EventArgs e)
        {
            RadGrid1.MasterTableView.IsItemInserted = true;
            RadGrid1.MasterTableView.Rebind();
        }
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
            {
                GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
                RadComboBox combo = insertItem.FindControl("RadComboBox1") as RadComboBox;
                combo.AutoPostBack = true;
                combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged);
                Button Save = insertItem.FindControl("btnSave") as Button;
                Save.Click += new EventHandler(Save_Click);
                Button cancel = insertItem.FindControl("btnCancel") as Button;
                cancel.Click += new EventHandler(Cancel_Click);
            }
        }
protected void Cancel_Click(object sender, EventArgs e)
        {
            Button Cancel = (Button)sender;
            GridEditFormInsertItem insertItem = (GridEditFormInsertItem)Cancel.NamingContainer;
            RadComboBox combo = insertItem.FindControl("RadComboBox1") as RadComboBox;
            Label lblRate = (Label)insertItem.FindControl("lblRate");
            RadNumericTextBox txtQauntityE = (RadNumericTextBox)insertItem.FindControl("txtQuantityE");
            Label lblAmount = (Label)insertItem.FindControl("lblAmount");
            combo.SelectedIndex = -1;
            lblRate.Text = "";
            txtQauntityE.Text = "";
            lblAmount.Text = "";
            RadGrid1.MasterTableView.IsItemInserted = false;
            RadGrid1.MasterTableView.Rebind();
        }
 
        protected void Save_Click(object sender, EventArgs e)
        {
            Button Save = (Button)sender;
            GridEditFormInsertItem insertItem = (GridEditFormInsertItem)Save.NamingContainer;
            RadComboBox combo = insertItem.FindControl("RadComboBox1") as RadComboBox;
            Label lblRate = (Label)insertItem.FindControl("lblRate");
            RadNumericTextBox txtQauntityE = (RadNumericTextBox)insertItem.FindControl("txtQuantityE");
            Label lblAmount = (Label)insertItem.FindControl("lblAmount");
            if (combo.SelectedIndex > 0 && txtQauntityE.Text != null)
            {
                DataRow drValues = dtValues.NewRow();
                drValues["Items"] = combo.SelectedItem.Text;
                drValues["Rate"] = lblRate.Text;
                drValues["Quantity"] = txtQauntityE.Text;
                drValues["Amount"] = lblAmount.Text;
                dtValues.Rows.Add(drValues);
                dtValues.AcceptChanges();
                RadGrid1.DataSource = dtValues;
                RadGrid1.Rebind();
                RadGrid1.MasterTableView.IsItemInserted = false;
                RadGrid1.MasterTableView.Rebind();
            }
            else
            {
                 
            }
        }
protected void combo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            RadComboBox combo = (RadComboBox)o;
            GridEditFormInsertItem insertItem = (GridEditFormInsertItem)combo.NamingContainer;
            Label lblRate = (Label)insertItem.FindControl("lblRate");
            SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["conn"].ToString());
            SqlCommand cmd = new SqlCommand("select [Rate] FROM [tblProducts] where ProductName=@ProductName", conn);
            cmd.Parameters.Add(new SqlParameter("@ProductName", combo.SelectedValue));
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            if (ds.Tables[0].Rows.Count > 0)
            {
                lblRate.Text = ds.Tables[0].Rows[0].ItemArray.GetValue(0).ToString();
            }
            RadNumericTextBox Quantity = (RadNumericTextBox)insertItem.FindControl("txtQuantityE");
            Quantity.Focus();
        }
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
            {
                GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
            }
        }
What's wrong with this,Am i missing something OR is this NOT POSSIBLE to insert temporary items to grid using data Table as Data Source.Plz help...

Thanks
Amit
Kostadin
Telerik team
 answered on 18 Sep 2012
3 answers
322 views
Hi,
I have a radgrid with an edit form template. There are multiple entry fields in the edit form.
I have a textbox in a radgrid that must be unique. I have created a custom validator for the insert so that it checks to make sure the value does not exist in the database and this works fine. However, if I use the same custom validator in the radgrid edit template, it will not let me update a row with the original value because it sees that it is already in the database. I use  page.isvalid to check before updating the radgrid. How do I get around this issue? Any help is appreciated! Thanks!
Radoslav
Telerik team
 answered on 18 Sep 2012
2 answers
134 views
I am having one heck of a time getting QTP to play fair with these Telerik controls.  The most recent issue, being able to Set a value in an edit.  I can set the value using extra code but for some reason, when a search is invoked, it ignores the entered value and performs an open search.  Here's the QTP code including all the code lines that won't work :(.
    'Enter Branch Office name for LookUp
      '''vSearchedit = "name:=ctl00\$c\$NameTextBox
    Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).Click
    Wait 1
    'Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).Set brNameIn
    'Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).Type brNameIn
    'Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).Object.Value = brNameIn
    'Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).Object.Click
 
'   ''''have to use this ReplayType technique gotta love telerik
Setting.WebPackage("ReplayType") = 2
    Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).set brNameIn
    Setting.WebPackage("ReplayType") = 1
 
    Wait 1
 
    Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).Click
 
    Wait 1
 
    didSet = Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).GetROProperty("value")
    If didSet <> "" Then
        Wait 1
        'Press the Search button
        Browser(vBrowser).Page(vPage).WebButton("name:=Search").Click
    Else
        Reporter.ReportEvent micFail, "Set Entity Search", "Unable to set the search value.  Check your code!!!!"
        ExitTestIteration  
    End If

Why in the world would QTP be able to see a value in the edit, but the value is ignored when the search is invoked?  It's not a problem with the search itself as it works if I manually enter my filter into the edit.  I am also including the source from the edit in question in case that might help...
<span class="riSingle RadInput RadInput_Office2007" id="ctl00_c_NameTextBox_wrapper" style="width: 180px;"><input name="ctl00$c$NameTextBox" tabIndex="2" class="riTextBox riEnabled" id="ctl00_c_NameTextBox" style="width: 165px;" type="text" size="20" _events="[object Object]" control="[object Object]" RadInputValidationValue="" /><input name="ctl00_c_NameTextBox_ClientState" id="ctl00_c_NameTextBox_ClientState" type="hidden" autocomplete="off" value='{"enabled":true,"emptyMessage":"","validationText":"","valueAsString":""}' /></span>


Thanks in advance,

Cathy
Vasil
Telerik team
 answered on 18 Sep 2012
1 answer
76 views
Im building a web app using the MVC archirecture (MVC3).  Is it somehow possible to use the RadScheduler in an mvc applcation ?
If so, are there any examples ?
Plamen
Telerik team
 answered on 18 Sep 2012
1 answer
60 views
Hi All,

iam runing into to some techincal issue,i have telerik text box which is customized and i have EnableExtendedEditor icon control which will open text editor to change the value of textbox but when i disable EnableExtendedEditor it s not working i.e not disabling.

my code is like below

<tempo:TextBox runat="server" ID="txtMasterAIName" LabelCssClass="label" ControlCssClass="control" EnableExtendedEditor="true">
                                            <TextBox Width="200px" />
                                                <Label Text="Name:"></Label>
                                            <Validator CssClass="validation" PropertyName="MASTER_AI_NAME" SourceTypeName="CGI.ESG.TEMPO.ViewEntity.AIMasterView, CGI.ESG.TEMPO.ViewEntity"
                                                EnableClientScript="true" />
                                        </tempo:TextBox>

in javascript iam disabling like

 function OnClientSelectedIndexChanged(sender, eventArgs) {
            var item = eventArgs.get_item().get_value();
            var licensePersonCode = sender.get_attributes().getAttribute("LicensePersonCode");
            if (item == licensePersonCode) {
                var txtMasterAIName = $find('<%= txtMasterAIName.ClientID %>');
                txtMasterAIName.EnableExtendedEditor = false;
                launchLicenseeDefinitionWindow();
                return true;
            }

but its throwing javascript if i mention txtMasterAIName.EnableExtendedEditor = false; like object null


below is my custome textbox code
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TempoTextBoxControl.ascx.cs" Inherits="CGI.ESG.TEMPO.Web.CommonControls.TempoTextBoxControl" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="CGI.ESG.TEMPO.Web" Namespace="CGI.ESG.TEMPO.Web.UIBase" TagPrefix="tempo" %>

<asp:Panel ID="pnlLabel" runat="server">
    <span id="lblValidatorFlag" runat="server" class="reqfield">*</span>
    <asp:Label ID="lblText" runat="server" AssociatedControlID="txtData" EnableViewState="false"></asp:Label>
</asp:Panel>
<asp:Panel ID="pnlControl" runat="server">
    <telerik:RadTextBox ID="txtData" runat="server">
    </telerik:RadTextBox>
    <tempo:ExtendedEditorPopup ID="edtPopup" runat="server" TextBoxID="txtData" NavigateUrl="~/Pages/AdvancedEditor.aspx"
        OnModalOK="popupExtendedEditor_ModalOK" OnModalShow="popupExtendedEditor_ModalShow" RadWindowID="wndEditor">
    </tempo:ExtendedEditorPopup>
    <tempo:ClientDataAnnotationValidator ID="valData" runat="server" ControlToValidate="txtData" />
</asp:Panel>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using Telerik.Web.UI;
using CGI.ESG.TEMPO.Web.UIBase;
using System.Configuration;
using System.Reflection;
using CGI.ESG.TEMPO.Common.Aspects;
using System.Text;
using System.ComponentModel.DataAnnotations;

namespace CGI.ESG.TEMPO.Web.CommonControls
{
    [Themeable(true)]
    public partial class TempoTextBoxControl : TempoCommonUserControl
    {
        #region events
        public event EventHandler TextChanged
        {
            add { txtData.TextChanged += value; }
            remove { txtData.TextChanged -= value; }
        }
        #endregion

        #region properties
        protected override string TooltipDefaultText
        {
            get { return lblText.Text; }
        }

        public bool EnableExtendedEditor
        {
            get { return (bool?) ViewState["extEditor"] ?? true; }
            set { ViewState["extEditor"] = value; }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [PersistenceMode(PersistenceMode.InnerProperty)]
        [NotifyParentProperty(true)]
        [Category("Label Settings")]
        public Label Label
        {
            get { return lblText; }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [PersistenceMode(PersistenceMode.InnerProperty)]
        [NotifyParentProperty(true)]
        [Category("TextBox Settings")]
        public RadTextBox TextBox
        {
            get { return txtData; }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [PersistenceMode(PersistenceMode.InnerProperty)]
        [NotifyParentProperty(true)]
        [Category("Validator Settings")]
        public override ClientDataAnnotationValidator Validator
        {
            get { return valData; }
        }

        public string RequiredFieldIndicatorText
        {
            get { return lblValidatorFlag.InnerText; }
            set { lblValidatorFlag.InnerText = value; }
        }

        #region Label properties
        public string LabelCssClass
        {
            get { return pnlLabel.CssClass; }
            set { pnlLabel.CssClass = value; }
        }
        #endregion

        #region TextBox properties
        public string ControlCssClass
        {
            get { return pnlControl.CssClass; }
            set { pnlControl.CssClass = value; }
        }

        public string Text
        {
            get { return txtData.Text; }
            set { txtData.Text = value; }
        }

        public bool AutoPostBack
        {
            get { return txtData.AutoPostBack; }
            set { txtData.AutoPostBack = value; }
        }
        #endregion
        #endregion

        #region methods
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
        }


        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
        }

        public override string ToolTip
        {
            get
            {
                return txtData.ToolTip;
            }
            set
            {
                txtData.ToolTip = value;
            }
        }

        public bool ReadOnly
        {
            get { return txtData.ReadOnly; }
            set { txtData.ReadOnly = value; }
        }

        protected void popupExtendedEditor_ModalShow(object sender, ModalOpenEventArgs e)
        {
            URLBuilder builder =new URLBuilder(URLBuilder.ServerBaseUrl() + "Pages/AdvancedEditor.aspx");
            builder["mode"] = this.ReadOnly ? "ro" : "rw";
            if (txtData.MaxLength > 0)
            {
                builder["len"] = this.txtData.MaxLength;
            }
            builder["title"] = this.lblText.Text.Replace(":","").Replace("*","");
            e.Url = builder.Url;
        }

        protected void popupExtendedEditor_ModalOK(object sender, ModalCloseEventArgs e)
        {
            if (!this.ReadOnly)
            {
                string newData = e.Result == null ? string.Empty : e.Result as string;
                if(newData != this.Text)
                {
                    this.Text = newData;
                    if (this.Page is TempoPage)
                    {
                        TempoPage page = this.Page as TempoPage;
                        page.IsDirty = page.TrackDirty;
                    }
                }
            }
        }
        #endregion

        protected override void InitializeValidator()
        {
            if (!string.IsNullOrEmpty(valData.SourceTypeName) && !string.IsNullOrEmpty(valData.PropertyName))
            {
                Type dataType = valData.GetValidatedType();
                PropertyInfo property = valData.GetValidatedProperty(dataType);
                object[] stringLengthAttributes = property.GetCustomAttributes(typeof(StringLengthAttribute), true);
                if (stringLengthAttributes.Length > 0)
                {
                    StringLengthAttribute attrib = stringLengthAttributes[0] as StringLengthAttribute;
                    if (attrib.MaximumLength > 0)
                    {
                        txtData.MaxLength = attrib.MaximumLength;
                    }
                }
                object[] requiredAttribute = property.GetCustomAttributes(typeof(RequiredAttribute), true);
                if (requiredAttribute.Length > 0)
                {
                    RequiredValidator = true;
                }
                else
                {
                    RequiredValidator = false;
                }
            }
            else
            {
                RequiredValidator = false;
            }
            ValidatorInitialized = true;
            edtPopup.Visible = txtData.MaxLength > 20 && EnableExtendedEditor != false;
        }

        protected override void SetReadOnly()
        {
            txtData.ReadOnly = true;
        }

        protected override System.Web.UI.HtmlControls.HtmlGenericControl RequiredIndicator
        {
            get { return lblValidatorFlag; }
        }
    }
}

please help me out to resolve the issue
Antonio Stoilkov
Telerik team
 answered on 18 Sep 2012
1 answer
95 views

 



Hi,

I have a quick question . In Telerik’s website,

(http://www.telerik.com/) we see this slider/menu bar at the top. When we click on button next to ‘Product families’ it closes or opens menu. What control does it use? Is it using Telrik controls? We want similar function in our website. I tried using RadMenu but I could not find a way to have Open/Close button at the top of menu for closing and opening menu.

Any help would be appreciated.

 

Thanks,

Kate
Telerik team
 answered on 18 Sep 2012
5 answers
334 views
How can we set the default skin sort style to GridTemplateColumn? It is working for GridBoundColumn but not for GridTemplateColumn. I have tried different colors from the Sortedbackcolor but I couldn't find the default color. Can somebody please help me with this?

<telerik:GridTemplateColumn HeaderText="Status" SortedBackColor="???" SortExpression="Active">
</telerik:GridTemplateColumn>

-Sree  
Galin
Telerik team
 answered on 18 Sep 2012
6 answers
105 views
I am using v2011.3.527.35 and I am having a rendering issue with the RadToolBar in IE8.  Please see attachment (RadToolBar2001.jpg).  There seems to be some overlapping or incorrect offset.  There is a default skin to use the "Default" theme.  The OnLoad function only set the visibility.  I am using the previous versions images, I believe.  Suggestions?

<telerik:RadToolBar ID="RadToolBar1" runat="server" EnableRoundedCorners="true" Style="float: right;"
                    OnButtonClick="MainToolbar_ButtonClick" OnClientButtonClicking="OnClientButtonClicking">
        <Items>
            <telerik:RadToolBarButton CommandName="Back" Text="Back" ImageUrl="~/Images/BackButton.gif" />
            <telerik:RadToolBarButton CommandName="Export" OnLoad="InquiryOrMaintenanceControl_Load" Text="Export" ImageUrl="~/Images/Export.gif" />
            <telerik:RadToolBarButton CommandName="Reset" OnLoad="InquiryOrMaintenanceControl_Load" Text="Reset" ImageUrl="~/Images/Reset.gif" />
            <telerik:RadToolBarButton CommandName="DeleteAll" OnLoad="DeleteAllButton_Load" Text="Delete All" ImageUrl="~/Images/Delete.gif" DisabledImageUrl="~/Images/Delete_d.gif" />
            <telerik:RadToolBarButton CommandName="Retrieve" OnLoad="InquiryOrMaintenanceControl_Load" Text="Retrieve" ImageUrl="~/Images/Retrieve1.gif" />
            <telerik:RadToolBarButton CommandName="Import" OnLoad="MaintenanceOnlyControl_Load" Text="Upload" ImageUrl="~/Images/uploadIcon.gif" />
        </Items>
</telerik:RadToolBar>

Thanks,
Rob
Kate
Telerik team
 answered on 18 Sep 2012
3 answers
171 views
I have a custom skin. I want to replace radcombobox with asp:dropdownlist.

I have following setting
<telerik:RadFormDecorator runat="server" ID="RadFormDecorator1" DecoratedControls="Select" />

It works fine but i want to change the font size of dropdownlist. For that i am using following style but it doesn't work. What else am i missing.
<style type="text/css">
       .rfdSelect_SkinName .rfdSelectOuter
       {
           font: 12px "Segoe UI" , Arial, sans-serif !important;
       }
   </style>



Bozhidar
Telerik team
 answered on 18 Sep 2012
3 answers
204 views
I am experiencing a problem where RADComboBox does not display the dropdown in Firefox, Chrome, or Opera.  IE9 does work.

Please help
Nencho
Telerik team
 answered on 18 Sep 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?