1 Replies - 1815 Views - Last Post: 18 March 2011 - 04:14 AM Rate Topic: -----

#1 pratyushakandala  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 23-March 10

How to sort alphabetically text in the textbox using asp(C#)

Posted 18 March 2011 - 12:31 AM

Can we sort the text alphabetically while entering the data into the textbox and to the database??
I mean if we enter in non alphabetical order it should sort and set it in alphabetical order

ex: Text we are entering like: java, c, donot, cpp
it should now sort it in alphabetical order and store in the database as : c, cpp ,dotnet, java

If there is any method kindly help me to know about it??
Is This A Good Question/Topic? 0
  • +

Replies To: How to sort alphabetically text in the textbox using asp(C#)

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,958
  • Joined: 21-March 08

Re: How to sort alphabetically text in the textbox using asp(C#)

Posted 18 March 2011 - 04:14 AM

Are you wanting to store the data in the same field in the database?

To sort it in the textbox, simply split the string on the comma, which puts it into an array. Then sort the array, then put the comma back in.

As for the database, if you want to store the 4 values in 4 different ROWS, then there is no need to sort them, as you can write a SQL to sort them when you want to retrieve them. Now if you want to store them in 1 field together, then simply save them to the database after you have sorted them for the textbox.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1