Re: Sorting problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Alvin Bruney [MVP] (vapor)
Date: 08/23/04


Date: Mon, 23 Aug 2004 11:43:12 -0500

what you will need to do is either parse the xml before you load it and
change the type to int16 for the appropriate node or read in the xml as
before, create another datatable with the correct schema and shallow copy
the information to the new table

-- 
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Arda Coskun" <a@a.com> wrote in message 
news:%23C6ZGGNiEHA.536@TK2MSFTNGP11.phx.gbl...
>I did;
>
> DataSet oData = new DataSet();
>
> oData.Tables.Add("HighScores");
>
> oData.ReadXml(Server.MapPath("HighScores.xml"));
>
> oData.Tables[0].Columns[2].DataType = Type.GetType("System.Int16");
>
> DataView oView = new DataView(oData.Tables[0]);
>
> oView.Sort = "Score DESC";
>
> DataGrid1.DataSource = oView;
>
> DataGrid1.DataBind();
>
> But it gives an error, you cannot change the type of column after you
> created it. What can I do, thanks?
>
> "Arda Coskun" <a@a.com> wrote in message
> news:eSXrnaBiEHA.3548@TK2MSFTNGP09.phx.gbl...
>> Thanks Mr. Cheng, but how I didn't create a DataTable, how can I set that
>> columns behavious as int?
>>
>>
>> "Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
>> news:i2#GMv1hEHA.2228@cpmsftngxa10.phx.gbl...
>> > Hi Sarp,
>> >
>> > From your description, I think the sorting problem is likely caused by
> the
>> > DataColumns' value in the Datatable, you can have a check in the 
>> > certain
>> > columns's DataType. Because when sorting , different data type has
>> > different sorting behavior. As for the condition you met that the rows
> is
>> > sorted as
>> >  23, 3, 44, 5
>> >
>> > It is likely that the columns is sorted as "string" type rather than 
>> > int
>> or
>> > long (number type). Please have a check and try manually set the
>> > DataColumns' DAtaType in the DataTable.
>> >
>> > Thanks.
>> >
>> > Regards,
>> >
>> > Steven Cheng
>> > Microsoft Online Support
>> >
>> > Get Secure! www.microsoft.com/security
>> > (This posting is provided "AS IS", with no warranties, and confers no
>> > rights.)
>> >
>> > Get Preview at ASP.NET whidbey
>> > http://msdn.microsoft.com/asp.net/whidbey/default.aspx
>> >
>> >
>>
>>
>
> 


Relevant Pages

  • Re: I can not read a small file from NTEXT field in the database
    ... new XML datatype instead. ... Are you simply storing the contents of the XML file, ... That wouldn't be a ntext ... If you're working with SQL Server locally, ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Importing XML files to SQL Database using SSIS.
    ... I was successful to use Data Conversion component. ... the the package get bloced on XML Source component itself.. ... Convert Data to a Different Data Type Using the Data Conversion ... you may try to change datatype of column in XML source by using the ...
    (microsoft.public.sqlserver.dts)
  • Re: XML Collating sequence
    ... Just to add to what Bob said, XML uses binary comparisons for comparison and sorting. ... Efficient, but does not account for the little things we've grown accustomed to like dictionary sorting, accent insensitivity, case insensitivity, etc. ... Case sensitivity, Accent sensitivity? ...
    (microsoft.public.sqlserver.xml)
  • Re: Custom sorting through xslt extension object
    ... > I don't have a source xml but let me give you a scenario. ... the sorting mechanism won't be alphabetical. ... > sorting order may be defined by the application arbitrarily. ...
    (microsoft.public.dotnet.xml)
  • Re: sorting a dataset
    ... Ideally, I would like to return the data in structured hierarchical xml, eg: ... I know I can copy my dataset into a dataview and sort the ... >> are sorting a dataview. ...
    (microsoft.public.dotnet.framework.adonet)