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.