My apologies but I forgot to mention that I am getting the data from a .NET web
service which is a dataset and then returned via string (XML) using the .NET
function
String strConn =
ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection dbConnection = new SqlConnection(strConn);
String strCommand = "SELECT SupplierID, CompanyName, ContactName,
ContactTitle, Address FROM Suppliers ";
SqlDataAdapter objCommand = new SqlDataAdapter(strCommand,
dbConnection);
DataSet DS = new DataSet();
objCommand.Fill(DS);
dbConnection.Close();
dbConnection = null;
DataTable DT = DS.Tables[0];
return DS.GetXml();
So, basically, I think the SupplierID which is numeric originally becomes a
string. How can I then prior to binding the same to the datagrid control,
convert its data type back to numeric so that when I perform a sort, it would
sort the supplierID interpreting it as a numeric value?
Thanks.
________________________________
From: markgoldin_2000 <[email protected]>
To: [email protected]
Sent: Monday, 18 May, 2009 23:44:33
Subject: [flexcoders] Re: modify item before binding to datagrid
Here is what I am doing.
column definition:
<mx:DataGridColumn headerText=" Block" dataField="tcbkcd" sortCompareFunction
="sortNumericCol umnTrackTotal" />
and:
private function sortNumericColumnTr ackTotal( itemA:Object, itemB:Object) :int
{
return ObjectUtil.numericC ompare(itemA[ TrackTotal. col], itemB[TrackTotal.
col]);
}
where TrackTotal is a DG's id.
HTH
--- In flexcod...@yahoogro ups.com, Angelo Anolin <angelo_anolin@ ...> wrote:
>
>
> Hi.
>
> I am quite new in Flex and would like to ask a simple question.
>
> I am retrieving datasets from a .NET webservice and binding the same to a
> datagrid. The datagrid comes with a feature that when you click on any of
> the headers, the column is sorted ASC or DESC.
>
> Now, one column which I am binding to is originally a numeric column. But
> when it binds to the datagrid, it's data type becomes string. Is it possible
> that prior to binding the said column to the datagrid, I would be able to
> convert it back to its numeric data taype? Since sorting the column in a
> string format would give a different result as compared to sorting the same
> column in a numeric format.
>
> Thanks.
>
> Regards.
>