I've done quite a bit of searching and reading, and maybe I just don't get it. Here's my problem.
I have a RadGrid with a nested Detail table. The Detail Table is configured to use a Form Template. To bind the values in the Form Template, I'm using markup that looks like this:
<asp:Label ID="lblID" runat="server" Text='<%# DataBinder.Eval( Container, "DataItem.ServerPowerID" ) %>' ></asp:Label> |
<asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update"%>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PowerInsert" : "PowerUpdate" %>'/> |
<asp:Button ID="btnCancel" Text="Cancel" CausesValidation="false" runat="server" CommandName="Cancel"/> |
if (e.CommandName == "PowerUpdate") |
{ |
GridEditableItem editedItem = e.Item as GridEditableItem; |
CMDB.ServerPower power = new CMDB.ServerPower(Convert.ToInt32((editedItem.FindControl("lblID") as Label).Text)); |
power.ServerID= (Convert.ToInt32((editedItem.FindControl("lblServerID") as Label).Text)); |
power.ServerPowerNameID = Convert.ToInt32((editedItem.FindControl("ddlServerPowerName") as DropDownList).SelectedValue); |
power.ServerPowerCircuitID = Convert.ToInt32((editedItem.FindControl("ddlServerPowerCircuit") as DropDownList).SelectedValue); |
power.ServerPowerNotes = (editedItem.FindControl("tbNotes") as TextBox).Text; |
power.Save(User.Identity.Name.ToString()); |
ServerRadGrid.Rebind(); |
} |
The problem is that editedItem is continually null. Since this code works on non-nested grids with success, I assume that I'm not referencing the nested grid's editable item correctly. Can someone either point me to a post/tutorial that shows me what the correct way to reference these controls on the nested grid are, or better yet just show me the light with this example?