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

How to insert new row using GridFootItem button

8 Answers 309 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raja M
Top achievements
Rank 1
Raja M asked on 01 Feb 2012, 11:06 AM
Hi,

In rad grid I have button in Footer. When I click this "AddorUpdateButton" need to update all the edited records. Its working fine.
But When I am using Add New Record button from above the header and then when I click "AddorUpdateButton" its won't take new record its taking only Edited row only.

Please help me on this..!


Thanks & Regards,
Raja M

8 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 01 Feb 2012, 11:24 AM
Hello,

// put grid in to insert mode
        RadGrid1.MasterTableView.IsItemInserted = true;
        RadGrid1.Rebind();
 
 
 // get all Edited Items
        foreach (GridEditableItem item in RadGrid1.EditItems)
        {
        }
        // get Inserted Items
        GridEditableItem Inserteditem = RadGrid1.MasterTableView.GetInsertItem();


Thanks,
Jayesh Goyani
0
Raja M
Top achievements
Rank 1
answered on 02 Feb 2012, 11:47 AM
Hi Jayesh,

Its working fine. Thanks a lot..!
I am facing one more issue on the DetailTables. I am not able to get the DetailTable Items using GridFooterItem.
foreach (GridDataItem dataItem in radGrdGauge.MasterTableView.Items)
{
}
When I am using the above code I just get only the Parent Grid Items only.

Could you pls help me on this.


Thanks & Regards,
Raja M
0
Accepted
Shinu
Top achievements
Rank 2
answered on 02 Feb 2012, 11:56 AM
Hello Raja,

I suppose you want to access the detail table view. Here is the sample code.
C#:
if (e.Item.OwnerTableView.Name == "DetailTable")
{
 GridTableView table= (GridTableView)e.Item.OwnerTableView;
 GridDataItem parentItem = (GridDataItem)table.ParentItem;
}

-Shinu
0
Raja M
Top achievements
Rank 1
answered on 02 Feb 2012, 12:42 PM
Hi Shinu,

Its working fine. Thank u very much...!
I just use the above syntax with slight modification inside Item Command.
foreach (GridDataItem dataItem in e.Item.OwnerTableView.Items)
{
}



Regards,
Raja M
0
Raja M
Top achievements
Rank 1
answered on 07 Feb 2012, 06:09 PM
Hi Jayesh,

In Item Command I am  able to update multiple records.
When I am using button for update its update properly in the DataBase but  not refresh in the RadGrid.
 
if (e.CommandName == RadGrid.UpdateCommandName)
{
       
e.Item.OwnerTableView.Rebind();
}


Could u pls help me on this..!
0
Shinu
Top achievements
Rank 2
answered on 08 Feb 2012, 05:25 AM
Hello Raja,

RadGrid  will automatically refresh after Update/Insert/Delete operation if you are binding the Grid in the NeedDataSource event.

-Shinu.
0
Raja M
Top achievements
Rank 1
answered on 08 Feb 2012, 10:00 AM
Hi Shinu,

I am using Item Command to update Multiple records but I am not using default Rad Grid Insert/Update/Delete.
Inside Item Command after updating all my data I just call RadGrid1.Rebind().It goes to the NeedDataSource Event without latest updated data. But in Database the values are updated.

Any Idea..!

protected void radGrdWellInfo_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
  if (e.CommandName == "UpdateAllWellInformationData")
  {
     foreach (GridDataItem dataItem in radGrdWellInfo.MasterTableView.Items)
     {
       update Values;
     }
  }
  radGrdWellInfo.Rebind();//It fires the NeedDataSource Event
}

0
Andrey
Telerik team
answered on 10 Feb 2012, 04:16 PM
Hello,

Please check this help article which illustrates how to perform batch Updates in RadGrid.

Kind regards,
Andrey
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Grid
Asked by
Raja M
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Raja M
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Andrey
Telerik team
Share this question
or