Fog Creek Software
Discussion Board




Lemme guess, you can do it in .Net

Why would Microsoft  implement data binding in Internet Explorer without providing a programmable interface to localized formatting?

For instance, you load a recordset that has date and currency fields into your DSO (XML/RDS), but you can't specify how you want the date/currency displayed unless you do it on the backend (in the SQL).

This pretty much makes databinding useless.

Anyone know of a way to do this that *doesn't* involve the server?  I see the "dataFormatAs" attribute, but it doesn't do anything.

Wayne
Monday, June 07, 2004

At a guess, and it may be entirely nonsense, it sounds like this is XML being used as output with presentation mixed.

Although in truth, if you have the physical data, whether its XML or not I can't see why you couldn't parse it and present it anyway you like, even if it was opaque to something like XSLT and if it is XML why can't it be styled?

Simon Lucy
Tuesday, June 08, 2004

Not positive with WebForms, but you can do that in WinForms databinding.

  --Josh

JWA
Tuesday, June 08, 2004

When you say "databinding in internet explorer," I assume you're talking about XML Data Islands, and not ASP.NET webforms, right?

If that's the case, I would say it's underfeatured because it's taken MS several tries to get databinding right.  IE's Data Islands were just one more brick in the road.  Actually, I've never even heard of anyone using it outside a classroom...have they done anything new to it since IE5?

Anywho, if that is indeed what you are using, then you might try invoking the MSXML XSLT processor on the client w/ JavaScript to take in the original XML and output the properly formatted XML, which you then bind to your form.  I believe you can use the MSXML ActiveX control from JavaScript without causing any annoying browser security popups.

Of course, you could also walk the original doc's DOM tree w/ MSXML and JavaScript and modify the data that way, but that would be a lot slower for any sizable set of records.

And if data islands just really aren't working for you, don't forget you can always do document.body.InnerHTML = xslt.Transform(...); =)

Joe
Tuesday, June 08, 2004

I thought about doing XSLT, but it's such a PITA. 

Their bindable elements should just raise an event called "OnBeforeBind" that allows you to modify the value before it is displayed.

Wayne
Tuesday, June 08, 2004

Shoulda woulda coulda ;-)

Joe
Tuesday, June 08, 2004

By the way, if you really really really want to do this with JavaScript events, there is an "ondatasetcomplete" event you could utilize as such:

<xml id="myds" src="mydoc.xml" ondatasetcomplete ="setFormats();" />

<script>
function setFormats()
{
    while(!event.recordset.EOF)
    {
        var p = "" + event.recordset("PRICE");
        event.recordset("PRICE") = formatCurrency(p);
        event.recordset.MoveNext();
    }
}

function formatCurrency(strVal) { ... }
</script>

Joe
Tuesday, June 08, 2004

*  Recent Topics

*  Fog Creek Home