473,387 Members | 1,859 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,387 software developers and data experts.

Format output of dynamic Datagrid columns

J.B
I have a datagrid that will display different datasets, (it runs
different sprocs based on a value in the querystring) but it will
always return 6 columns. The 5th and 6th columns are always Date and
Currency format, all others are strings.

I'd like to build one datagrid to handle this datagrid dynamically. I
have it working now, all except the formatting of the 5th (Date) and
6th (Currency) columns.

Since the headers for those columns will be different depending on the
situation (and the sprocs that is kicked off) I need to format these
columns on the fly.

I have this as my DataGrid:
<ASP:Datagrid id="dgAssetInfo"
runat="server"
AutoGenerateColumns="True"
CellPadding="5"
Font-name="Arial"
Font-size="11px"
OnItemDataBound="dgAssetInfo_ItemDataBound"

<AlternatingItemStyle BackColor = "#DDDDCC" />
<HeaderStyle CssClass="update-header" ForeColor="White" />
<ItemStyle CssClass="text" />
</asp:datagrid>

I am trying to format the Columns using ItemDataBound, basically
saying "make the 5th column look like a date" ({0:D} format).

I experimented with this, but no luck...

Sub dgAssetInfo_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs)

'Format 5th column as Date
E.Item.Cells(4).DataFormatString = {0:D}

'Format 6th column as Currency
E.Item.Cells(5).DataFormatString = {0:C}

End Sub

Can I do this in ItemDataBound? I've looked at the Properties of the
TableCell class but nothing looks like it will allow formatting of
each cell.

Any ideas on how to do this?? Should I be doing it differently (and
no, unfortunately, I can't modify the sprocs to format the data prior
to returning the data)
Nov 17 '05 #1
1 2290
Just an idea,

Why not letting your database formating the output data to date and
Currency format.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2

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

Similar topics

0
by: JP011 | last post by:
Hello I have hit a major road block when it comes to building my dynamic datagrid. To make a long story short I need a dynamic datagrid because my connection string could change and I need the...
2
by: Tamlin | last post by:
Hi all, I'm getting a bug with the datagrid object. I've created one from scratch, bound it to a dataview with 2 int32 columns and formatted the output as currency. I've found that when you...
6
by: Hutty | last post by:
I've looked around and have yet to find anything that would answer my question regarding formating a column in a datagrid. My grid looks like this as far as data" AMHQCON|51300.01|-3147 The...
0
by: optimizeit | last post by:
What I am attempting to do is import an Excel Workbook and display the worksheets in a datagrid dynamically. I am very close to getting this to work. I have to this point successfully imported a...
7
by: CanoeGuy | last post by:
I have been trying for the last two weeks to display a dynamic DataGrid. The data that I'm pulling from a SQL Server DB will have whole columns that will be either NULL or 0. I want to display...
2
by: PK | last post by:
Hi All, i got few questions to ask regarding about publishing dataset to html format !!! ------------------- PublishHTML("C:\Inetpub\wwwroot\Report.htm", myDataSet1.Tables("table01")) ...
0
by: KA NMC | last post by:
I have a dataGrid that is populated by SQL table. The Datagrid has two dynamic columns - that I created to for calculations. I want to sort the grid on frmload by one of the dynamic columns is that...
9
by: seep | last post by:
hi i m finding following error on the code that i wants to use to get all record from table via store procedure with paging. the error is : Input string was not in a correct...
0
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.