iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi,
I am exporting my grid to an XML file and was wondering if there is a way to change the name of the fields that get exported. For example, on the Grid I have a column defined as:
When it is exported to XML the Field name is CARRIER_STATE, I would like it to use the Caption name of "State" instead. Is this possible?
Also I would like to change a value of the field when it gets exported. For example a field in the database has the value of -1 but when I display it in the Grid, I change it to "**", but the export uses -1 but I want to use "**". Is this possible?
Thanks
John
WebGrid has “OnExport” server side event. You can handle the OnExport server side event, write customized exporting codes and set the event’s ReturnValue to false for cancelling default process. You can also have your scenario implemented by using this server side event.
Please try to use following code in order to change the name of the fields that get exported (in the following sample, I use “Shippers” table in Northwind.mdb file as the reference). The sample below shows how to change the “CompanyName” field into “Company”.
protected void WebGrid1_Export(object sender, ISNet.WebUI.WebGrid.ExportEventArgs e) { e.Table.Columns.GetNamedItem("CompanyName").Name = "Company"; }
In order to change a value of field, please try to use following code. The sample below shows how to change the value of a cell, from “United Package” into “United Package Service”.
protected void WebGrid1_Export(object sender, ISNet.WebUI.WebGrid.ExportEventArgs e) { e.Table.Rows[1].Cells.GetNamedItem("CompanyName").Text = "United Package Service"; }
Hope this helps.
Thanks, I will try out as soon as I can and let you know of any problems.
Yudi,
Your first example of changing a column name works, although you can't add a space, like "Carrier State" the export replaces the space with "_0020_".
In the second example in changing the Text value doesn't work. You can change the Value but not the Text that gets exported.
thanks
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname