Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Sort Routine Problem

Reply
Thread Tools

Sort Routine Problem

 
 
Tom Carter
Guest
Posts: n/a
 
      01-19-2004
I have created a datagrid that has edit/update/cancel links and whose
header is sortable. I have one glitch which I hope sounds familar to
someone ...

I click the edit butoon and the textboxes are populated with data
from a different record than the record which I selected. This
problem occurs only after I sort the data.

What am I missing???

-- here's the code:

private void masterDataGrid_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEvent Args e)
{
//Logic Handles Bi-Directional Sorting using SortHandler Hidden
Label
switch (SortHandler.Text.EndsWith(" ASC"))
{
case true :
SortHandler.Text = e.SortExpression.ToString () + " DESC";
break;
case false:
SortHandler.Text = e.SortExpression.ToString () + " ASC";
break;
}

dv.Sort = SortHandler.Text;
this.masterDataGrid.DataSource = dv;
this.masterDataGrid.DataBind();

}

-- heres the edit routine:
private void masterDataGrid_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
this.masterDataGrid.EditItemIndex = e.Item.ItemIndex;
this.masterDataGrid.DataBind ();
}
 
Reply With Quote
 
 
 
 
Tom Carter
Guest
Posts: n/a
 
      01-20-2004
Hi Team,

The problem is solved. I extrapolated the answer based on another
online answer. Essentially I needed to reset the Sort expression
before binding the data on each postback of the page.

i.e.
this.masterDataGrid.DataSource = dv;
dv.Sort = SortHandler.Text;
this.masterDataGrid.DataBind ();

Thanks anyhow -
--
~~~~~~~~~~~~~
Tommie Carter
--

http://www.velocityreviews.com/forums/(E-Mail Removed) (Tom Carter) wrote in message news:<(E-Mail Removed). com>...
> I have created a datagrid that has edit/update/cancel links and whose
> header is sortable. I have one glitch which I hope sounds familar to
> someone ...
>
> I click the edit butoon and the textboxes are populated with data
> from a different record than the record which I selected. This
> problem occurs only after I sort the data.
>
> What am I missing???
>
> -- here's the code:
>
> private void masterDataGrid_SortCommand(object source,
> System.Web.UI.WebControls.DataGridSortCommandEvent Args e)
> {
> //Logic Handles Bi-Directional Sorting using SortHandler Hidden
> Label
> switch (SortHandler.Text.EndsWith(" ASC"))
> {
> case true :
> SortHandler.Text = e.SortExpression.ToString () + " DESC";
> break;
> case false:
> SortHandler.Text = e.SortExpression.ToString () + " ASC";
> break;
> }
>
> dv.Sort = SortHandler.Text;
> this.masterDataGrid.DataSource = dv;
> this.masterDataGrid.DataBind();
>
> }
>
> -- heres the edit routine:
> private void masterDataGrid_EditCommand(object source,
> System.Web.UI.WebControls.DataGridCommandEventArgs e)
> {
> this.masterDataGrid.EditItemIndex = e.Item.ItemIndex;
> this.masterDataGrid.DataBind ();
> }

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Merge Sort in C - array output is same as input after sort routine completes rkk C Programming 9 09-24-2006 08:30 PM
CODE: Generic Sort Routine Kamilche Python 1 08-23-2004 11:27 AM
Perl Sort Routine Arthur Perl Misc 2 02-12-2004 04:51 PM
AspNet DataGrid won't fire sort routine PatLaf ASP .Net Web Controls 4 10-30-2003 05:26 PM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM



Advertisments