473,394 Members | 1,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Editing in a gridview

I'm in the RowDataBound event for a gridview. my money fields and dates
are in unedited format. The following works fine but is this the easiest
way? Isn't there a way to apply formating to the string without having to
convert the string to its native type and then back to an edited string?

double mydouble = double.Parse(e.Row.Cells[totalcharge].Text);
e.Row.Cells[totalcharge].Text = mydouble.ToString("c");
DateTime myDateTime = DateTime.Parse(e.Row.Cells[designdate].Text);
e.Row.Cells[designdate].Text = myDateTime.ToShortDateString();
Thanks,
T
Jan 19 '07 #1
2 1168
Tina

Unless you have row-specific rules you can avoid RowDataBound
alltogether and change your column defs to something like:

<asp:BoundField DataFormatString="{0:c}" DataField="totalcharge" ...
<asp:BoundField DataFormatString="{0:d}" DataField="designdate"
HtmlEncode="false"...

Remember the HtmlEncode when formatting dates!

Mark

On Jan 19, 1:08 pm, "Tina" <TinaMSeab...@nospamexcite.comwrote:
I'm in the RowDataBound event for a gridview. my money fields and dates
are in unedited format. The following works fine but is this the easiest
way? Isn't there a way to apply formating to the string without having to
convert the string to its native type and then back to an edited string?

double mydouble = double.Parse(e.Row.Cells[totalcharge].Text);
e.Row.Cells[totalcharge].Text = mydouble.ToString("c");
DateTime myDateTime = DateTime.Parse(e.Row.Cells[designdate].Text);
e.Row.Cells[designdate].Text = myDateTime.ToShortDateString();
Thanks,
T
Jan 19 '07 #2
my data is created at run time.
"dunny" <mr******@gmail.comwrote in message
news:11*********************@38g2000cwa.googlegrou ps.com...
Tina

Unless you have row-specific rules you can avoid RowDataBound
alltogether and change your column defs to something like:

<asp:BoundField DataFormatString="{0:c}" DataField="totalcharge" ...
<asp:BoundField DataFormatString="{0:d}" DataField="designdate"
HtmlEncode="false"...

Remember the HtmlEncode when formatting dates!

Mark

On Jan 19, 1:08 pm, "Tina" <TinaMSeab...@nospamexcite.comwrote:
> I'm in the RowDataBound event for a gridview. my money fields and
dates
are in unedited format. The following works fine but is this the easiest
way? Isn't there a way to apply formating to the string without having
to
convert the string to its native type and then back to an edited string?

double mydouble = double.Parse(e.Row.Cells[totalcharge].Text);
e.Row.Cells[totalcharge].Text = mydouble.ToString("c");
DateTime myDateTime = DateTime.Parse(e.Row.Cells[designdate].Text);
e.Row.Cells[designdate].Text = myDateTime.ToShortDateString();
Thanks,
T

Jan 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: AmitKu | last post by:
I've got the Gridview going at full speed, and I've enabled editing, but when I click on the "edit" button, this ugly editing UI comes up. Well it's not ugly, but it's not great either. How do I...
0
by: HP | last post by:
Hi there I have a datalist control with some bound controls in its Item Template and a gridview bound to one of those fields (residing also in Item Template). I've found out that when I click...
3
by: cpnet | last post by:
I have a GridView which I'm populating from an ObjectDataSource (give the GridView a DataTable). The GridView will have about 20 rows, and only one editable column. The editable column consists...
5
by: =?Utf-8?B?QWRhciBXZXNsZXk=?= | last post by:
Hi All, I have a GridView inside the EditItemTemplate of a FormView. Both FormView and GridView are data bound using an ObjectDataSource. When the FormView's ObjectDataSource object has a...
5
by: =?Utf-8?B?Z3V5?= | last post by:
How do you enable editing in a GridView programatically rather than via its Tasks menu? Guy
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.