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

Updating All Rows w/ external button

1 Answer 187 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Philip Senechal
Top achievements
Rank 1
Philip Senechal asked on 04 Dec 2010, 01:53 AM
I'm almost there on this solution. I have a RadGrid that I received assistance with to create RadioButtons in the columns so that only one row value can be selected at a time per column. This works perfectly and now I'm trying to submit the results using an external button so that the values can be saved in the database. All of the rows are put into edit mode when the page loads. The problem is that the update command is only firing for the first row using my code...

Here is the code for the external button
protected void btn_submit_Click(object sender, EventArgs e)
{
    GridItem[] items = RadGrid1.MasterTableView.GetItems(GridItemType.EditItem);
 
    for (int i = 0; i < items.Length; i++)
    {
        int itemIndex = items[i].ItemIndex;
        if (RadGrid1.EditItems[i].ItemIndex == itemIndex)
        {
            (items[i] as GridEditableItem).FireCommandEvent("Update", String.Empty);
        }
    }
 
    RadGrid1.EditIndexes.Clear();
    for (int i = 0; i < RadGrid1.PageSize; i++)
        RadGrid1.EditIndexes.Add(i);
    RadGrid1.Rebind();
}


If I change this line...
if (RadGrid1.EditItems[i].ItemIndex == itemIndex)

so that "i" is the row index I want to submit, I can get the values to submit for that particular row.

I'm not sure why the for loop stops after the first run through though. Using this code, shouldn't it fire off the Update command for each row that it finds? I checked the value of items.Length and got 8 (which is correct...there are 8 rows), so it should run this 8 times and fire off the Update command for row indexes 0-7.

Let me know if I'm not understanding how this works properly...thanks =)

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Dec 2010, 06:19 AM
Hello,


The following documentation shows how to perform batch update on clicking a button which is placed outside.
Performing batch updates



-Shinu.
Tags
Grid
Asked by
Philip Senechal
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or