C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 08-14-2006, 08:04 AM   #1
Registered User
 
Join Date: May 2005
Posts: 22
Sorting and deleting with a DataView in ASP.NET 1.1

Now for the stupid question (even I, who is asking, thinks it is a dumb question. I have DataGrid on a WebForm in ASP.NET 1.1. I can bind a DataView to it and correctly delete from it or sort it.

So if I have the DataView bound, is there a reason why after it is sorted, if I try to get the primary key (just happens to be column 12) I would get the value of the item that's there with default sorting instead of what I can see?


Here's approxamatly what I do in my code:
Code:
public void LoadData(DataGrid myDataGrid, string sortExpression)
{
	sqlDataAdapter.Fill(myDataSet, "table");

	myDataSet.Tables["myTable"].DefaultView.Sort = sortExpression  /* sortExpression is set in the Sort event, then passed in */

	myDataGrid.DataSource = myDataSet.Tables["myTable"].DefaultView;
	myDataGrid.DataBind();
}


public void MyGrid_Delete(string primKey)
{
	foreach(DataRow currentRow in myDataSet.Tables["myTable"])
	{
		if (currentRow.Cells[11] == primKey)
		{
			currentRow.Delete();
			break;
		}
	}
	sqlDataAdapter.Update(myDataSet, "myTable");
}
When I click Delete, it looks like it returns to the default sort before deleting.
shuuhen is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
deleting structs in an array and sorting the array of structs[ascending].. Huskar C Programming 3 03-31-2009 12:34 PM


All times are GMT -6. The time now is 06:05 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22