Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datalist Order Problem

Status
Not open for further replies.

M444

Programmer
Feb 24, 2004
76
US
Hi All,

When I update the primary key of a row in my datalist no changes are made immediately to the datalist order. But when I go to edit another entry the rows sort in alpha order...

For example: I have a datalist with the following rows Primary Key, FirstName, LastName

the records appear like this in the datalist:
1, John, Doe
2, Jane, Doe
3, Tom, Flynn

If I change 1, John, Doe TO 4, John, Doe
The rows are update and look like this in the datalist:
4, John, Doe
2, Jane, Doe
3, Tom, Flynn

However, when I click to edit 4, John, Doe the items sort themselves to look like this!:
2, Jane, Doe
3, Tom, Flynn
4, John, Doe

And then it goes into edit mode for 2, Jane, Doe instead of 4, John, Doe!!!!


Anyone have this problem? or know how to fix it?
 
You'll have to post the relevant code...


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi ca8msm,

I appologize there was a lot of code..., some of it sensitive, and at the time I was not sure exactly what was relevant.

I did however discover a fix if anyone else has this issue.
SQL Server orders records by the primary key
Ie:
PK: 1
2
3
A
B etc.

When you update your PK in a dataset and update it in the database the datalist is not automaticaly sorted.

My solution is at the end of your update code do this:
Response.Redirect("datalistpage.aspx")
This should refill your dataset and datalist in the new order.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top