We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Unbound Appearance (Currency format)

Thread ID:

Created:

Updated:

Platform:

Replies:

106982 Feb 5,2013 02:27 PM Feb 20,2013 12:45 AM ASP.NET Web Forms (Classic) 5
loading
Tags: GridGroupingControl
Dale Norhern
Asked On February 5, 2013 02:27 PM

Hello,

 

I have a GridGroupingControl that is data bound to an asp:SqlDataSource.  I also have unbound columns that whose values are calculated in the code behind.  The grid is populated, and the calculated values all work as expected.  However, I cannot get the unbound cells to accept any formatting.  I have tried multiple methods, from modifying the appearance tag in the markup to setting properties on load or load complete and even setting explicit values on QueryCellStyleInfo.  Here is the aspx code I am using:

 

                        <Appearance>

                            <RecordFieldCell CellType="Currency" WrapText="False" CellValueType="System.Double"

                            Format="$###.##"></RecordFieldCell>

                        </Appearance>

 

What is interesting is if I place this exact same code on one of the bound columns, it formats perfectly?!?!?  I think the problem may be similar to the post here: http://www.syncfusion.com/support/forums/grid-windows/33912 from 2005.  Also of interest, I can set the color in the <Appearance> section and it gets applied (while the Currency formatting does not).

 

I need a method for showing a currency format for an unbound column in a GridGroupingControl.

 

Visual Studio 2010

.NET Framework 4.0

Essential Studio 10.4.0.71

VB.Net Code behind

 

 

Thanks!

 

 --Dale


Ranjithkumar R G [Syncfusion]
Replied On February 11, 2013 06:15 AM

Hi Dale,

 

Thanks for using Syncfusion products.

 

We are sorry for inconvenience caused. We are unable to reproduce the issue. We have prepared a simple sample and the same can be downloaded from the following links. 

Sample link:  sample-2.zip 

Could you please try the above sample and get back to us whether you are able to reproduce the issue? If not, could you please give more information or by reproducing the issue in the above sample so that we could sort out the issue and provide you with solution. The information provided would be of great help in resolving the issue.

 

Please let us know if you have any concerns.

 

Regards,

Ranjithkumar


Dale Norhern
Replied On February 12, 2013 11:03 AM

Ranjithkumar,

 

Thank you again for your very thorough response and sample.  The sample you supplied did NOT exhibit my problem.  It also did NOT match my requirements, however.  I have modified the sample to illustrate my issue (see the attachment sample-21166577707.rar).

 

Here is a list of the changes made from your sample.

 

Northwind database replaced with an older version to match my SQL Express version (no effect to the sample).

The function GetData() was commented out.

A new column was added (TestCurrency).

this.ggc.TableDescriptor.Columns[4].Appearance.AnyRecordFieldCell.Format = "$###.##"; was added to format the TestCurrency format to be currency.

<RecordFieldCell CellType="Currency" CellValueType="System.Double" Format="C" /> was added to the TestCurrency markup.

public void GridGroupingControl1_RowDataBound(object sender, RowDataBoundEventArgs e) was added to populate the TestCurrency cells as the table was loaded.

SqlDataSource1 was added as the table data source (to match my requirements).

Unused variables were commented out.

 

The screenshot (Unformatted.JPG in the attachment) shows that the formatting for the TestCurrency column is not applied.  I need this unbound calculated column to honor its formatting.

 

Thanks!



sample21166577707_b5704efd.rar

Ranjithkumar R G [Syncfusion]
Replied On February 13, 2013 02:04 AM

Hi Dale,

Thanks for your update.

We have analyzed your sample. In that we found you have cast the type ‘double’ to ‘string ’ to make a column in Grid and so the format ‘Currency’ does not getting apply for that column alone. We have added two columns with specifying the ‘Format’ as ‘C’ to make it work for integer columns.  Please let us know if you receive the error in ‘double’ datatype column in Grid.

Please let us know if you have any concern.

Regards,

Ranjithkumar.


Dale Norhern
Replied On February 13, 2013 05:17 PM

Ranjithkumar,

 

"we found you have cast the type ‘double’ to ‘string '" This is part of my problem.  From within the RowDataBound event I cannot find a method to set the cell value.  I expected a function like (e.Row.Cells[4].Value) but the only option is (e.Row.Cells[4].text).  I've tried many aproaches, but there are none that seem to work.

 

Was there supposed to be a sample attachment?  If so, it didn't come through.

 

Thanks!

-Dale

 

Ranjithkumar R G [Syncfusion]
Replied On February 20, 2013 12:45 AM

Hi Dale,

 

Sorry for the delay in getting back to you.

 

We suggest you to set the format of currency as illustrated below in RowDataBound event.

 

 public void GridGroupingControl1_RowDataBound(object sender, RowDataBoundEventArgs e)

    {

        if (e.Row != null)

        {

            if (e.Row.DisplayElement.Kind == DisplayElementKind.Record)

            {

                double nTest = 0.0;

                nTest = Convert.ToInt32(e.Row.Record.GetSourceIndex()) + 1;

                double nPi = nTest * Math.PI;

                e.Row.Cells[4].Text = string.Format("{0:C}", nPi);                

                

            }

        }

    }

 

 

Please let us know if you have any concern.

 

Regards,

Ranjithkumar.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;