This is a migrated thread and some comments may be shown as answers.

Modifying selected rows by code

2 Answers 59 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Manoj
Top achievements
Rank 1
Manoj asked on 15 Sep 2011, 12:53 AM
Hi Admin,

How can I modify particular column of selected rows. I don't want to save it to db. My Grid is bind to view in database by domain data source. I have tried following code. But it is not working.  My data model properties are readonly so not able to modify those. Please help. I am having time till tomorrow.

  

GridViewCell cell = null;
 foreach (var item in CurrentView.radGridView.SelectedItems)
 {
  cell = (item as GridViewRow).Cells[6] as GridViewCell;
  cell.IsInEditMode = true;
  cell.Value = "Voluntary";
 }

 

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 15 Sep 2011, 06:57 AM
Hi,

 SelectedItems are your data objects - not UI containers. You should cast them to your data item type if you want to get/set desired properties. 

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Manoj
Top achievements
Rank 1
answered on 15 Sep 2011, 05:57 PM
Thanks Vlad
I got way

 

 

 

 

 

int rowindex = 0;
            int colIndex = 0;
            GridViewCell cell = null;
            foreach (var item in CurrentView.radGridView.SelectedItems)
            {
                rowindex = 0;
                colIndex = 0;
                rowindex = CurrentView.radGridView.Items.IndexOf(item);
                colIndex = CurrentView.radGridView.Columns["AuditTypeDesc"].DisplayIndex;//.IndexOf(
                (CurrentView.radGridView.ItemContainerGenerator.ContainerFromItem(item) as GridViewRow).Cells[colIndex].Content = "Suggested";
            }

But Display index is not returning proper index(Having some collepsed column and also user can move columns). How I can get column index as per unique name.

Tags
GridView
Asked by
Manoj
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Manoj
Top achievements
Rank 1
Share this question
or