Thanks,
Your explanation makes sense to me. The XML file doesn't articulate the
type of data (which is numeric). The XML file is generated on the fly from
a COM object and is simply loaded into a dataview via the following
statements:
Dim xtr As XmlTextReader = New XmlTextReader(oXml, XmlNodeType.Document,
Nothing)
ds.ReadXml(xtr, XmlReadMode.Auto)
[oXml is a string variable.]
I will try to set the datatype on the DS or possily use the databind event.
Did want to much overkill like you said. If you could give me a little more
detail about ("consider specifying the data type for the generated
DataTable's columns") I would much appreciate it. Do you mean establish all
the columns of the DS manually?
Thanks for your response.
Larry
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,
the string formatting does not work if the underlying type (the type to be
formatted) is string itself as string formatting works from other types to
String. You would need to manage this say in ItemDataBound event, i.e
catch the string value, cast to the correct type and then apply formatting.
Might seem bit overkill, though. So how are you getting the XML? By loading into
DataSet? If yes, you might consider specifying the data type for the
generated DataTable's columns so that you get typed reference to the data
wehn binding (and again formatting to work)
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"McNutt Consulting" <la***@mcnutt-consulting.com> wrote in message
news:T9********************@giganews.com... I'm trying to implement a datagrid with dynamically created columns.
The data is coming out of a very simple XML file, and it's bound through a
dataview.
The datagrid is just a shell definition with no column definitions in
the .aspx file.
The grid is binding fine with all the data being displayed, but my
numeric columns aren't being formatted. I'm using the "dataformattextstring",
but it doesn't seem to be working. Is there anything else I need to do?
Thanks for any help you can give,
Larry
example of my code:
Dim dgc as datagridcolumn
dgc.HeaderText = "Title"
dgc.DataNavigateUrlField = "account"
dgc.DataNavigateUrlFormatString = "detail.aspx={0}"
dgc.DataTextField = "account"
dgc.DataTextFormatString = "{0:n}"
dg.Columns.Add(dgc)