Which approach is better in term of saving the data? How to handle this?
Posted
by dewacorp.alliances
on Stack Overflow
See other posts from Stack Overflow
or by dewacorp.alliances
Published on 2010-06-10T03:40:34Z
Indexed on
2010/06/10
3:42 UTC
Read the original article
Hit count: 150
Hi there
I have Telerik grid within a Telerik grid. Due to I have a different view between insert and edit mode, so as per suggested I have to use UserControl instead. Inside this control, it could have another Telerik grid plus bunch of ASP.NET textboxes. This thing works well.
My dilemma is this:
Scenario 1: Handling the save in the user control - OnClick event
I have a button to save this. I need to get the value of the "selected grid" so I am using this snippet below and again works well.
foreach (GridDataItem dataItem in radgrdTariffNetworkDistributorRateItems.SelectedItems)
{
string ID = dataItem.OwnerTableView.DataKeyValues[dataItem.ItemIndex]["SupplierRateItemID"].ToString();
}
But then how do I get the id of the parent grid where this control sit? I use the following this event to save: protected void bttnNetworkTariffReviewItemInsert_Click(object sender, EventArgs e) the e of course not the right one though?!?!?
GridDataItem parentItem = (GridDataItem)e.Item.OwnerTableView.ParentItem;
string reviewID = parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["ID"].ToString();
Scenario 2: Handling the save in the page instead (OnInsertCommand on the master grid)
With this approach works well to get id of the grid etc BUT I am having a problem to get selected grid in the UserControl and plus couple controls value. How do I make this feasible?
Logically, I should handle this at the user control level to save but again because the user control relying on the child grid I am having trouble to get this value.
I am appreciated your suggestion.
© Stack Overflow or respective owner