PC Review


Reply
Thread Tools Rate Thread

DataGrid selecting rows

 
 
=?Utf-8?B?Z2FyeTc1ODQ=?=
Guest
Posts: n/a
 
      16th Oct 2004
My task is a little more complicated than that because of my user
requirements. In my app I have made the DataGrid read only because there is
concern that the users will inadvertently delete rows. I need the Delete to
be a two-step process in which the user selects rows on the datagrid and then
clicks a button to confirm that the selected rows will be deleted.

So, my challenge is just to identify the rows that are selected and then
pass these rows to a procedure for deletion. I thought I could do this with
the IsSelected property but it doesn't seem to be working.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?UmFrZXNoIFJhamFu?=
Guest
Posts: n/a
 
      17th Oct 2004
Hi Gary,

When you select a row in a datagrid, it is possible to find it's actual
location in the datatable by using the bindingcontext, regardless of the sort
applied in the grid.

But in your case, you need the opposite requirement. When you use the
IsSelected method, you need to pass the row index of the row in the grid. But
ASAIK there is no straightforward method to find out the location of a row in
a grid if you know the actual location of the row in the underlying binding.

One workaround will be to add a hidden column in the Datatable with
incremental values with respect to the current data sort. Whenever the sort
changes, you will have to update the column values.

When you select multiple rows and press the delete button, you could find
out the datarow by using the row's primary key. And you could pass the
IsSelected method the index by obtaining the index value from our new column.

Let me know if I could be of more assistance.

HTH,
Rakesh Rajan

"gary7584" wrote:

> My task is a little more complicated than that because of my user
> requirements. In my app I have made the DataGrid read only because there is
> concern that the users will inadvertently delete rows. I need the Delete to
> be a two-step process in which the user selects rows on the datagrid and then
> clicks a button to confirm that the selected rows will be deleted.
>
> So, my challenge is just to identify the rows that are selected and then
> pass these rows to a procedure for deletion. I thought I could do this with
> the IsSelected property but it doesn't seem to be working.
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Selecting rows on a datagrid via code ewingate@gmail.com Microsoft C# .NET 2 9th May 2007 09:07 PM
Selecting multiple rows in a datagrid? =?Utf-8?B?RGF2aWQ=?= Microsoft C# .NET 0 31st Oct 2005 07:59 AM
DataGrid selecting rows =?Utf-8?B?Z2FyeTc1ODQ=?= Microsoft ADO .NET 4 15th Sep 2005 07:59 AM
Selecting DataGrid rows Dan Microsoft ASP .NET 1 1st Mar 2004 06:16 PM
Selecting and Unselecting Rows in a DataGrid Tim Rogers Microsoft Dot NET Framework Forms 3 26th Jun 2003 09:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:08 AM.