Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
117 views
Hi,
  I have a dynamic created grid and the Grid have GridTemplateColum which contains a hyperlink. I want To format Hyperlink Text to currency. I tried below, but does not work
string Price = ((DataRowView)container.DataItem)[colname].ToString();
           link.Text = String.Format("{0:C}", Price);
#region Create GridTemplate column
   private void CreateTemplateColumn(DataTable dt, ref RadGrid rg, string FromYearMonth, string ToYearMonth)
   {
       foreach (DataColumn dc in dt.Columns)
       {
           if (dc.ColumnName == "Vendor" || dc.ColumnName == "vendorID")
               continue;
           if (dc.ColumnName != "Vendor" && dc.ColumnName != "VendorID")
           {
               string ColName = dc.ColumnName;
               string[] DPMNameAndID = ColName.Split(';');
               string DPMName = DPMNameAndID[0];
               string DMPId = DPMNameAndID[1];
               GridTemplateColumn templateColumn = new GridTemplateColumn();
               templateColumn.ItemTemplate = new MyTemplate(ColName, FromYearMonth, ToYearMonth, DPMName, DMPId);
               templateColumn.SortExpression = ColName;
               templateColumn.HeaderText = DPMName;
               templateColumn.HeaderStyle.Font.Bold = true;
               templateColumn.FooterStyle.Font.Bold = true;
               templateColumn.FooterAggregateFormatString = "{0:C}";
               templateColumn.DataField = ColName;
               templateColumn.Aggregate = Telerik.Web.UI.GridAggregateFunction.Sum;
               rg.MasterTableView.Columns.Add(templateColumn);
           }
       }
   }
 
   private class MyTemplate : ITemplate
   {
 
       protected HyperLink SealeByVendorTrans;
 
       private string colname;
       private string _fromDate;
       private string _toDate;
       private string _DPMName;
       private string _DPMId;
       public MyTemplate(string cName, string fromDate, string toDate, string DPMName, string DPMId)
       {
           colname = cName;
           _fromDate = fromDate;
           _toDate = toDate;
           _DPMName = DPMName;
           _DPMId = DPMId;
       }
       public void InstantiateIn(System.Web.UI.Control container)
       {
           SealeByVendorTrans = new HyperLink();
           SealeByVendorTrans.ID = colname;
           SealeByVendorTrans.DataBinding += new EventHandler(SealeByVendorTrans_DataBinding);
           container.Controls.Add(SealeByVendorTrans);
       }
       void SealeByVendorTrans_DataBinding(object sender, EventArgs e)
       {
           HyperLink link = (HyperLink)sender;
           GridDataItem container = (GridDataItem)link.NamingContainer;
           string Price = ((DataRowView)container.DataItem)[colname].ToString();
           //txtPrice.Text = String.Format("{0:C}", price);
           link.Text = String.Format("{0:C}", Price);
              
           link.NavigateUrl = "HinoPartsDashBoardTransactions.aspx?type=Vendor&TransType=V&DPMName=" + _DPMName + "&DPM=" + _DPMId + "&from=" + _fromDate + "&to=" + _toDate + "&VendorID=" + ((DataRowView)container.DataItem)["VendorID"].ToString() + "&Vendor=" + ((DataRowView)container.DataItem)["Vendor"].ToString();
       }
   }
   #endregion
Maria Ilieva
Telerik team
 answered on 02 Jul 2013
10 answers
732 views
Hello!

I am using RadTextBoxes so users input their email and password information for login.

Here is the code snippet (everything is enclosed in a RadAjaxPanel):

E-mail:
 <telerik:RadTextBox ID="rtbEmail" runat="server" EmptyMessage="E-mail" MaxLength="100" />
 <asp:RegularExpressionValidator ID="revEmail" Display="Dynamic" ErrorMessage="Invalid e-mail address." CssClass="error"
                                 ValidationGroup="vgLogin" ControlToValidate="rtbEmail" runat="server"
                                 ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" />
 <asp:RequiredFieldValidator ID="rfvEmail" Display="Dynamic"  runat="server" ErrorMessage="No e-mail address." CssClass="error" ValidationGroup="vgLogin" ControlToValidate="rtbEmail" />
 <br />
 <br />
Password:
 <telerik:RadTextBox ID="rtbPassword" runat="server" EmptyMessage="Password" MaxLength="100" TextMode="Password" />
 <asp:RequiredFieldValidator ID="rfvPassword" Display="Dynamic" runat="server" ErrorMessage="No password." CssClass="error" ValidationGroup="vgLogin" ControlToValidate="rtbPassword" />


No matter how many times I input the email and password my browser doesn't remember it. I have it turned on though, because other sites remember my inputs normally.

Thanks for your assistance.

Sincerely, Jure
Maria Ilieva
Telerik team
 answered on 02 Jul 2013
1 answer
91 views
Hi,

I'm having an issue with the RadAsyncUpload control where if the control is disabled on the server side, then enabled on the client side, the 'Select' button doesn't work.

I have narrowed this down to the <input type="file" class="ruFileInput" id="....file0" .....> element not being rendered when disabled on the server side.

If I manually add what that element 'should' be (including it's name/id etc) then it starts working as expected.

Serverside I am calling control.Enabled = false;

Clientside I am calling jsControl.set_enabled(true);

On the same topic, by disabling the control server side, the following other elements appear to get left out too (although they don't appear to affect my use of the control):

* List item's ID (<li>) -> id="....row0"
* 'file' input (described above)
* label for='....file0'
* 'ruDropZone' div

Can you give any suggestions as how to be disable this control serverside while still being able to use it after re-enabling client side? I have considered handling all disabling/enabling client side which would probably work ok but it seemed a bug for it not to work the way I have described??

Cheers,

Andrew
Hristo Valyavicharski
Telerik team
 answered on 02 Jul 2013
1 answer
72 views

Hi,

A have a problem with asp.net radgrid editing:

In my page there is a grid with edittemplate and when two different client click the item and open an editform and If one of the clients save, the other one sees the good data yet, but if he saves it overwrites an other record because the rowindex shifted meanwhile.

How can i solve this problem?
What is the best solution for this?

Please help me.

Thanks.
Csaba
Top achievements
Rank 1
 answered on 02 Jul 2013
3 answers
280 views
Hi,

I'm using Asp.Net MVC application in which i've used rad grid. Application runs fine, but when i set allowpaging = true, above error appears.
Please note that there is no code-behind file of aspx file. Here is the markup code.

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<WeBOC.DAL.Vessel>" %>
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>
 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
 
    <form id="form1" runat="server">
 
    <h2>Vessels<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
        </telerik:RadScriptManager>
    </h2>
     
    <%
        RadGrid1.DataSource = ViewData["Vessels"];       
        RadGrid1.DataBind();
    %>
 
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false"
        CellSpacing="0" GridLines="None" Skin="WebBlue" AllowPaging="True">
        <MasterTableView>
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
 
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn DataField="VIR_NO" HeaderText="VIR No." />
                <telerik:GridBoundColumn DataField="INBOUND_VOY_NO" HeaderText="I/B Voyage" />
                <telerik:GridBoundColumn DataField="OUTBOUND_VOY_NO" HeaderText="O/B Voyage" />
                <telerik:GridBoundColumn DataField="VESSEL_NAME" HeaderText="Vessel Name" />
                <telerik:GridBoundColumn DataField="ARRIVAL_DATE" HeaderText="Arrived" />
                <telerik:GridBoundColumn DataField="STATE" HeaderText="Phase" />
            </Columns>
 
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
 
<PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
        </MasterTableView>
 
<PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
 
<FilterMenu EnableImageSprites="False"></FilterMenu>
 
    </telerik:RadGrid>
 
     
    </form>
 
</asp:Content>

And hers is the stack trace..

   at System.Web.UI.ScriptControlManager.RegisterScriptControl[TScriptControl](TScriptControl scriptControl)
   at System.Web.UI.ScriptManager.RegisterScriptControl[TScriptControl](TScriptControl scriptControl)
   at Telerik.Web.UI.RadDataBoundControl.RegisterScriptControl()
   at Telerik.Web.UI.RadDataBoundControl.ControlPreRender()
   at Telerik.Web.UI.RadDataBoundControl.OnPreRender(EventArgs e)
   at Telerik.Web.UI.RadComboBox.OnPreRender(EventArgs e)
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.AddedControl(Control control, Int32 index)
   at System.Web.UI.ControlCollection.Add(Control child)
   at Telerik.Web.UI.GridPagerButtonBuilder.CreatePageSizeDropDown(Panel container)
   at Telerik.Web.UI.GridPagerButtonBuilder.CreatePageSize(Panel container)
   at Telerik.Web.UI.GridPagerItem.InitializePagerItem(GridColumn[] columns)
   at Telerik.Web.UI.GridPagerItem.SetupItem(Boolean dataBind, Object dataItem, GridColumn[] columns, ControlCollection rows)
   at Telerik.Web.UI.GridTableView.CreateTopPagerItem(Boolean useDataSource, GridColumn[] copiedColumnSet, Boolean isPagingEnabled, GridTHead thead)
   at Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource)
   at Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource)
   at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)
   at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)
   at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
   at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
   at Telerik.Web.UI.GridTableView.PerformSelect()
   at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
   at Telerik.Web.UI.GridTableView.DataBind()
   at Telerik.Web.UI.RadGrid.DataBind()
   at ASP.views_vessel_index_aspx.__Renderform1(HtmlTextWriter __w, Control parameterContainer) in d:\Projects\WeBOC.MVC\WeBOC.MVC\Views\Vessel\Index.aspx:line 19
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
   at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Control.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in d:\Projects\WeBOC.MVC\WeBOC.MVC\Views\Shared\Site.Master:line 29
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Control.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Page.Render(HtmlTextWriter writer)
   at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Application get stuck at RadGrid1.DataBind( ); I've searched alot but unable to find the solution. Any help would be appreciated.

Thanks
Ovais
Muhammad
Top achievements
Rank 1
 answered on 02 Jul 2013
10 answers
120 views
Hi,
 My telerik controls version is 2013.1.417.40. My combo boxes are appearing in gray color. I want to change the combobox color to  white.
our old telerik controls version was 2012.2.724.40 and the combo box color was white.
we want to maintain the color consistency of the combo boxes with the new telerik controls.
Any help would be appreciated.
Thanks in advance.
Ivan Zhekov
Telerik team
 answered on 02 Jul 2013
3 answers
319 views
Based on a search condition I need to hide the nestedview template and not show the caret symbol to the left of each grid row.

I have tried the following code on prerender, itemcreated, item databound events of the grid.It does not show the nested view but still displays the caret symbol which I don't need.

Is there a way to hide the template including the caret symbol?

Prerender:

foreach (GridDataItem item in Grd.Items)

{

if (chk != "1")

{

GridNestedViewItem nesteditem = (GridNestedViewItem)Grd.MasterTableView.GetItems(GridItemType.NestedView)[0];

nesteditem.Visible = false;

nesteditem.Enabled = false;

nesteditem.Display = false;

}}

OnItemcreated

protected void OnGrd_ItemCreated(object sender, GridItemEventArgs e)

 {

if (e.Item is GridNestedViewItem)

GridNestedViewItem nestedItem = (GridNestedViewItem)e.Item; 

var chk = "1";
if (chk != "1")

{

nestedItem.Visible = false;

}}}

OnItemDataBound:

if ((e.Item is GridNestedViewItem))

 {var p= e.Item.FindControl("GrdNest") as RadGrid;

 {chk="1"; 

if (chk == "1")

{nestedItem.Visible = true;

 p.Visible = true;

 p.DataSource = results;

 p.DataBind();

}

else

{

nestedItem.Visible = false;

nestedItem.Display = false;

 p.Visible = false;

}}}

 

Maria Ilieva
Telerik team
 answered on 02 Jul 2013
1 answer
96 views
Hi
I have 4 grids on batch mode on a page, I have to updated all of them in once with a Save button, How do I get only the records which are changed in each grid?
Thanks
Angel Petrov
Telerik team
 answered on 02 Jul 2013
1 answer
102 views
I am a newer web developer.  I am working with ASP.NET 4  and C# in visual studio 2012. Also, I am using the latest version of the UI controls for ASP.NET.

I have a page where I need to be able to load a bunch of user controls(ascx pages).  I used the following example :
http://demos.telerik.com/aspnet-ajax/ajax/examples/common/loadingusercontrols/defaultcs.aspx
to start building what I needed. I have 6-7 different controls but for this question I am going to relate to only 3 of them.

I have a master page that I am building off of.  That master page has the RadScriptManager and RadAjaxPanel.  The panel is set up as follows:

<div class="contentContainer">
    <div class="contentPanel">
        <telerik:RadAjaxPanel runat="server">
            <asp:ContentPlaceHolder ID="MainContent" runat="server" />
        </telerik:RadAjaxPanel>
    </div>
</div>

Then, in my page I have the following:

<telerik:RadAjaxPanel runat="server">
    <div class="tabsContainer">
        <asp:LinkButton ID="lblDetails" runat="server" CssClass="headerTabItem" Text="Details"  />
        <asp:LinkButton ID="lblDrafts" runat="server" CssClass="headerTabItem" Text="Drafts"/>
        <asp:LinkButton ID="lblFees" runat="server" CssClass="headerTabItem" Text="Fees"/>
     </div>
    <div class="contentContainer">
        <div class="panelContent">
            <asp:Panel ID="displayPanel" runat="server"/>  
        </div>
    </div>
        <div class="controlsContainer">
        </div>
</telerik:RadAjaxPanel>

Then my code behind is as follows:

    private string LatestLoadedControlName
    {
        get
        {
            return (string)ViewState["LatestLoadedControlName"];
        }
        set
        {
            ViewState["LatestLoadedControlName"] = value;
        }
    }
 
    #endregion
 
 
    #region Events
 
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        lblDetails.Click += new System.EventHandler(this.lb_Details_Click);
        lblDrafts.Click += new System.EventHandler(this.lb_Drafts_Click);
        lblFees.Click += new System.EventHandler(this.lb_Fees_Click);
        lblPayments.Click += new System.EventHandler(lb_Payments_Click);
        lblDeposits.Click += lb_Deposits_Click;
        lblTransactions.Click += lb_Transactions_Click;
        lblNotes.Click += lb_Notes_Click;
        lblStatements.Click += lb_Statements_Click;
 
    }
 
 
 
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadUserControl(LatestLoadedControlName ?? "ClientDetail.ascx");    
        }
 
 
    }
 
    override protected void OnInit(EventArgs e)
    {
        InitializeComponent();
        base.OnInit(e);
    }
 
 
    protected void Page_PreRender(object sender, EventArgs e)
    {
 
    }
 
    #endregion Events
 
    private void lb_Details_Click(object sender, System.EventArgs e)
    {
        LoadUserControl("ClientDetail.ascx");
    }
 
    private void lb_Drafts_Click(object sender, System.EventArgs e)
    {
        LoadUserControl("Drafts.ascx");
    }
 
    private void lb_Fees_Click(object sender, System.EventArgs e)
    {
        LoadUserControl("Fees.ascx");
    }  
 
    /// <summary>
    /// Loads the user control.
    /// </summary>
    /// <param name="controlName">Name of the control.</param>
    public void LoadUserControl(string controlName)
    {
 
        if (!controlName.Contains(".ascx"))
        {
            //TODO: Make this better with substring
            controlName = controlName.Replace("MainContent_", "");
            controlName += ".ascx";
        }
 
        if (LatestLoadedControlName != null)
        {
            Control previousControl = displayPanel.FindControl(LatestLoadedControlName.Split('.')[0]);
             
            if (!Object.Equals(previousControl, null))
            {
                this.displayPanel.Controls.Remove(previousControl);
            }
        }
 
        string userControlID = controlName.Split('.')[0];
 
        Control targetControl = displayPanel.FindControl(userControlID);
        
        if (Object.Equals(targetControl, null))
        {
            UserControl userControl = (UserControl)this.LoadControl(controlName);
 
            //slashes and tildes are forbidden
            userControl.ID = userControlID.Replace("/", "").Replace("~", "");
 
            this.displayPanel.Controls.Add(userControl);
 
            LatestLoadedControlName = controlName;
        }
 
    
 
}


It will load pages the first time.  I can then also swap drafts and fees but I can not return to the details page.  In my debugging I am not seeing it ever finding the old control and removing it.  At this point I am at a loss.  

Am I going down the right path?  Should I do this a different way?

Thanks for your time in advance.




Andrey
Telerik team
 answered on 02 Jul 2013
1 answer
69 views

Hello, I'm writing you because now I'm having problems about session state in web farm and telerik controls. My web server now is configured in SLQSever mode but when I try start up my site this error show up (see attached file).


By other hand, I wondering you  if there is any upgrade about telerik controls to help me to prevent this error.

 

Best Regards, many thanks

Jayesh Goyani
Top achievements
Rank 2
 answered on 02 Jul 2013
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?