Telerik Forums
UI for ASP.NET AJAX Forum
8 answers
1.5K+ views
Whatever I do (and I've tried many ideas already given in these forums) i cannot get my columns to show currencies, just plain numeric values.

I want my grid to show the "buyprice" and totalcost columns as "{0:C}" or "{0:$###.##}"

Here's my code:

.aspx
<telerik:RadGrid  
        ID="RadGrid1" runat="server" 
        Width="95%" 
        OnNeedDataSource="RadGrid1_NeedDataSource" 
        > 
        <MasterTableView AutoGenerateColumns="false"
            <Columns> 
                <telerik:GridBoundColumn DataField="id" Visible="false" ReadOnly="true"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="symbol" HeaderText="Symbol"  ReadOnly="true" ></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="buyprice" HeaderText="Buy Price" DataType="System.Decimal" DataFormatString="{0:C}" ></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="totalcost" HeaderText="Total Cost" DataType="System.Decimal" DataFormatString="{0:C}" ></telerik:GridBoundColumn> 
                <telerik:GridButtonColumn  ConfirmText="Are you sure?" ConfirmDialogType="Classic" ButtonType="ImageButton" ImageUrl="/images/delete.gif"CommandName="Delete"> 
                </telerik:GridButtonColumn> 
            </Columns> 
        </MasterTableView> 
    </telerik:RadGrid> 

.aspx.cs
        protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
        { 
            string XMLFilePath = getXMLPath(); 
 
            DataSet ds = new DataSet(); 
            ds.ReadXml(XMLFilePath); 
 
            DataView dv = new DataView(ds.Tables[0]); 
            dv.Sort = "datecalculated DESC"
 
            RadGrid1.DataSource = dv
             
        } 

.xml
<?xml version="1.0" encoding="utf-8"?> 
<calculations> 
  <calculation id="1" symbol="SYM1" buyprice="3.4" totalcost="831.483" datecalculated="06/30/2010" /> 
  <calculation id="2" symbol="SYM2" buyprice="10.74" totalcost="1088" datecalculated="06/17/2010" /> 
</calculations> 

am I missing anything? Is my method of populating RadGrid1 causing this, can string formatting not be applied to boundcolumns? (I did try using GridNumericColumn, still without success).
Jr
Top achievements
Rank 1
 answered on 02 Mar 2012
3 answers
440 views
Hi,

check all checkboxes in radgrid on button click.  button is placed outside radgrid. I tried thos method on button click.

                CheckBox chb;
                for (int i = 0; i < RadGrid1.Items.Count; i++)
                {
                    chb = (CheckBox)RadGrid1.Items[i].FindControl("chkSelectItem");
                    chb.Checked = true;
                }
This will fix the check boxes in the radgrid on that page. if I move to another page(pagination), it will be unchecked in there.
Thanks in advance.
Pavlina
Telerik team
 answered on 02 Mar 2012
1 answer
136 views
Hello,

I have a Treeview called RadTreeView1 which is already populated as follows, this is working perfect:

Do While RS.Read
    If RS(0) = 1 Then
        Dim Node As New RadTreeNode
        Node.Text = (RS(2) & " " & RS(3) & " (" & RS(1) & ")")
        Node.Value = RS(1)
        Node.Checkable = True
        RadTreeView1.Nodes.Add(Node)
    Else
        Dim foundNode As RadTreeNode = RadTreeView1.FindNodeByValue(RS(5))
        If foundNode IsNot Nothing Then
            Dim Node As New RadTreeNode
            Node.Text = (RS(2) & " " & RS(3) & " (" & RS(1) & ")")
            Node.Value = RS(1)
            Node.Checkable = False
            foundNode.Nodes.Add(Node)
        End If
    End If


I've set the root values checkable=true and all the children as checkable=false (so the user can only check or uncheck the root values). Each node has a value which is an integer number.

What I need to do is to click on a button, and retrieve all those nodes that are checked. Im using the code below but its not working:

Imports Telerik.Web.UI
Partial Class Hierarchy_Compression
    Inherits System.Web.UI.Page
    Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        Dim Compression As IList(Of RadTreeNode) = RadTreeView1.CheckedNodes
        For Each node As RadTreeNode In Compression
            If node.Checked = True Then
                Response.Write(node.Value)
            End If
        Next
    End Sub
End Class

What am I doing wrong?!

Thanks.
Princy
Top achievements
Rank 2
 answered on 02 Mar 2012
1 answer
150 views
Hi,
  I'm using DNN 6.0 and I've implemented custom PDF export functionality from RadGrid where I had to disable Ajax on start of PDF export request. I accomplished disabling Ajax using below code

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <ajaxsettings>              
                 <telerik:AjaxSetting AjaxControlID="btnExport">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="btnExport" />                        
                    </UpdatedControls>
                 </telerik:AjaxSetting>
        </ajaxsettings>
        <ClientEvents OnRequestStart="RequestStarted" />
</telerik:RadAjaxManager>

where in RequestStarted, I disable the Ajax. Problem here is - when I use this code in my local, it's all working good. When I put it in my dev environment, I get an error
"An error occurred. DotnetNuke.Services.Exceptions.PageLoadException: Multiple controls with the same ID "...." were found. FindControl requires that controls have unique IDs ... "

When I remove the RadAjaxManager piece of code from my UI in dev site, my module shows up properly. Can anyone help me on what can be done here to get around the exception?

Thanks.
Ananth
Ananthalvan
Top achievements
Rank 1
 answered on 02 Mar 2012
1 answer
519 views
I have noticed since upgrading my Telerik.Web.UI to 2012.1.215.40 I have not been able to hit enter from a RadTextBox to fire the default button. I have tested it on many pages in my project, and every page is "broken".

I have made a test page, and the problem occurs with the RadTextbox with or without being wrapped in a RadAjaxPanel.

EDIT: RadMaskedTextBox and RadNumericTextBox work properly with the enter key. RadDatePicker, RadTimePicker, RadComboBox do not fire the submit button.

Any idea on how to fix this issue?

Here is my sample page:
<%@ Page Language="C#" AutoEventWireup="true" %>
<script runat="server">
     
    protected void Page_Load(object sender, EventArgs e)
    {
        for (int i = 0; i < 10; i++)
        {
            rcb1.Items.Add(new RadComboBoxItem(i.ToString(), i.ToString()));
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ltlMessage.Text = DateTime.Now.ToString() + " - Postback Fired.";
    }   
</script>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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>
    </head>
    <body>
        <form id="form1" runat="server">
            <telerik:RadScriptManager ID="rsm1" runat="server"></telerik:RadScriptManager>   
            <div>
     
                <asp:Panel ID="pnlSubmit" runat="server" DefaultButton="btnSubmit">                       
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
                    <telerik:RadTextBox ID="txtText" runat="server"></telerik:RadTextBox><br />
                    <telerik:RadDatePicker ID="rdp1" runat="server"></telerik:RadDatePicker><br />
                    <telerik:RadTimePicker ID="rtp1" runat="server"></telerik:RadTimePicker><br />
                    <telerik:RadComboBox ID="rcb1" runat="server" AllowCustomText="true">                  
                    </telerik:RadComboBox><br />
                    <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server">
                    </telerik:RadNumericTextBox><br />
                    <telerik:RadMaskedTextBox ID="RadMaskedTextBox1" runat="server" Mask="####">
                    </telerik:RadMaskedTextBox><br />
                    <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click"></asp:Button>
                    <br />
                    <asp:Literal ID="ltlMessage" runat="server"></asp:Literal>
                </asp:Panel>
            </div>
        </form>
    </body>
</html>
Princy
Top achievements
Rank 2
 answered on 02 Mar 2012
2 answers
523 views
I have a radgrid on my page. I want to move selected row up/down. There are some solutions I found. But in given example

sectionRowIndex is always -1. It is not working for IE*. Any other suggestion?

http://www.telerik.com/community/code-library/aspnet-ajax/grid/move-rows-up-down-using-radgrid-for-asp-net-ajax-prometheus.aspx

Thanks in advance
Meera
Top achievements
Rank 1
 answered on 02 Mar 2012
0 answers
91 views
This can be closed
Web Services
Top achievements
Rank 2
 asked on 01 Mar 2012
3 answers
190 views
hi

I have this Stored Proc and my grid is empty and no error. I have tested the proc and is returning me the result but not the grid.

How should i go about it? Thanks

Create Proc test
as
DECLARE @query VARCHAR(4000)
DECLARE @years VARCHAR(2000)
SELECT  @years = STUFF((SELECT DISTINCT
      '],[' + ltrim(Dyear)
                        FROM    Product2
                        ORDER BY '],[' + ltrim(Dyear)
                        FOR XML PATH('')
      ), 1, 2, '') + ']'
      

SET @query =
'SELECT * FROM
(
 SELECT prodId,Dyear,amount
 FROM Product2
)t
PIVOT (SUM(amount) FOR Dyear
IN ('+@years+')) AS pvt'

EXECUTE (@query)

Richard
Top achievements
Rank 1
 answered on 01 Mar 2012
2 answers
116 views
Greetings Telerik Community,

I am currently and successfully using the code block below to turn an edit column into a delete column. I do this because my customer wants in-line add and delete but no edit. My issue now is I need to do this for a column that is nested 1 level deep in a hierarchical grid. The column name is "EditColumn2". The problem is this column doesn't appear to exist when the PreRender is called and throws an exception. My guess is it is created on the fly when the expand arrow is clicked. Which event can I use to add a similar code block to so I can apply the same logic to turn an editboundcolumn into a delete column for the nested table?

protected void GridPreRender(object sender, EventArgs e)
{
    foreach (GridDataItem item in MaintGrid.MasterTableView.Items)
    {
        ImageButton btn = (ImageButton)item["EditColumn"].Controls[0];
        btn.CommandName = "Delete";
        btn.ToolTip = "Delete";
        btn.ImageUrl = "~/Stylesheets/Images/Delete3.gif";
        btn.OnClientClick = "javascript:if(!confirm('Are you sure you wish to delete this record?')){return false;}";
    }
}
Mike
Top achievements
Rank 1
 answered on 01 Mar 2012
0 answers
77 views
Hello,

I am using client-side binding grid, so all my columns are gridtemplatecolumn type and filled from web-service.
One of the columns is a result of some calculation.

<telerik:GridTemplateColumn HeaderStyle-CssClass='GridHeaderGreen ra' ItemStyle-CssClass='ra'
    HeaderText="Start day throughput" SortExpression="START_DAY_DATA.IO_PER_SECOND">
    <itemtemplate>
        <asp:Label ID="StartPerSecond" runat="server" />
    </itemtemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderStyle-CssClass='GridHeaderGreen ra' ItemStyle-CssClass='ra'
    HeaderText="End day throughput" SortExpression="END_DAY_DATA.IO_PER_SECOND">
    <itemtemplate>
        <asp:Label ID="EndPerSecond" runat="server" />
    </itemtemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderStyle-CssClass='GridHeaderGreen ra' ItemStyle-CssClass='ra'
    HeaderText="Throughput growth">
    <itemtemplate>
        <asp:Label ID="PerSecondDelta" runat="server" />
    </itemtemplate>
</telerik:GridTemplateColumn>


When I put SortExpression="(END_DAY_DATA.IO_PER_SECOND - START_DAY_DATA.IO_PER_SECOND)" into third column - I am getting the exception when trying to sort by this column.

I can't believe I can't solve this problem in a more elegant way than writing something like:
SELECT
  END_DAY_DATA.IO_PER_SECOND,
  START_DAY_DATA.IO_PER_SECOND
  END_DAY_DATA.IO_PER_SECOND - START_DAY_DATA.IO_PER_SECOND
........
and putting SortExpression="3" for third column! :(

UPDATE: Lack of time for experiments: so, I've used the last approach: SortExpression="3" :)
Alexander
Top achievements
Rank 1
 asked on 01 Mar 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?