Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Referencing Datagrid Rows while Datagrid is Sorted (http://www.velocityreviews.com/forums/t776123-referencing-datagrid-rows-while-datagrid-is-sorted.html)

MrMike 05-20-2005 08:44 PM

Referencing Datagrid Rows while Datagrid is Sorted
 
I see this question raised often elsewhere, but I haven't yet found an
answer. When a datagrid is sorted, referencing a specific row is a problem.
In my applications I frequently use datagrids and I must tell my users "If
you are going to edit/update/delete a record from a datagrid, make sure you
don't have it sorted first because you'll perform the action on the wrong
record."

Is there a way to work around the problem of sorting a datagrid and then
referencing it's records? Thanks.

Steve Goodyear 05-21-2005 05:01 AM

RE: Referencing Datagrid Rows while Datagrid is Sorted
 
Hi Mike,

It's no problem to let them sort still and also let them edit the data. Look
in the DataGridCommandEventArgs of the update event to get the DataGrid row
instead of EditItemIndex to get the updates for your DataTable. This way your
DataGrid can be more flexable:

private void DataGrid1_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string updatedText = e.Item.Cells[0].Text;
}

Cheers,
Steve Goodyear

MrMike 05-23-2005 12:02 PM

RE: Referencing Datagrid Rows while Datagrid is Sorted
 
Hi Steve,

Thank you very much for that valuable information!!

"Steve Goodyear" wrote:

> Hi Mike,
>
> It's no problem to let them sort still and also let them edit the data. Look
> in the DataGridCommandEventArgs of the update event to get the DataGrid row
> instead of EditItemIndex to get the updates for your DataTable. This way your
> DataGrid can be more flexable:
>
> private void DataGrid1_UpdateCommand(object source,
> System.Web.UI.WebControls.DataGridCommandEventArgs e)
> {
> string updatedText = e.Item.Cells[0].Text;
> }
>
> Cheers,
> Steve Goodyear



All times are GMT. The time now is 11:50 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.