OK, I know that I can use the NestedViewTemplate and from the code in that template reference values of the MainView data item. I have the example of using a NestedViewTemplate which contains another Grid and the gird in the template is bound to a DataSource server control.
I do not want to use SqlDataSource or any other data source control as my implementation is not utilizing these controls. I need to bind my grid in the NextedViewTemplate via code behind.
Problem, for testing I have an ASP:Label control that I am setting the Text property to a value from the Master Grid which works fine but, in the code behind event of RADGRID_ItemCreated when the NestedViewItem is the item being created the label control has not had it's Text property assigned yet.
Is there a more appropriate event I can use to bind my grid in the NestedViewTemplate to a value based on the corresponding row in the Master Table.
Here is a snippet of my current ASPX code:
Here is a snippet of the code from my code behind:
Again, I do not want to use a DataSource server control in the ASPX page to do this binding.
I do not want to use SqlDataSource or any other data source control as my implementation is not utilizing these controls. I need to bind my grid in the NextedViewTemplate via code behind.
Problem, for testing I have an ASP:Label control that I am setting the Text property to a value from the Master Grid which works fine but, in the code behind event of RADGRID_ItemCreated when the NestedViewItem is the item being created the label control has not had it's Text property assigned yet.
Is there a more appropriate event I can use to bind my grid in the NestedViewTemplate to a value based on the corresponding row in the Master Table.
Here is a snippet of my current ASPX code:
| <NestedViewTemplate> | |
| SessionID: <asp:Label ID="lblSessionID" runat="server" Text='<%# Eval("SessionID") %>' /><br /> | |
| Race Day ID:<asp:Label ID="lblRaceDayID" runat="server" Text='<%# Eval("RaceDayID") %>' /><br /> | |
| <telerik:RadGrid | |
| ID="rgLaps" | |
| runat="server" | |
| Skin="Default"> | |
| <MasterTableView | |
| DataKeyNames="SessionLapID" | |
| CommandItemDisplay="Top" | |
| EditMode="InPlace"> | |
| <CommandItemSettings AddNewRecordText="Add New Lap" RefreshText="Refresh" /> | |
| <Columns> | |
| <telerik:GridButtonColumn | |
| UniqueName="LapsDeleteColumn" | |
| Text="Delete" | |
| CommandName="Delete" /> | |
| <telerik:GridBoundColumn | |
| UniqueName="LapNumber" | |
| DataField="Number" | |
| HeaderText="Lap Number" /> | |
| <telerik:GridBoundColumn | |
| UniqueName="LapTime" | |
| DataField="Time" | |
| HeaderText="Lap Time" /> | |
| <telerik:GridBoundColumn | |
| UniqueName="LapIgnore" | |
| DataField="Ignore" | |
| HeaderText="Ignore Lap" /> | |
| <telerik:GridEditCommandColumn | |
| UniqueName="LapsEditCommandColumn" | |
| CancelText="Cancel" | |
| EditText="Edit" | |
| InsertText="Insert" | |
| UpdateText="Update" /> | |
| </Columns> | |
| <EditFormSettings | |
| CaptionFormatString="Edit details for lap with ID {0}" | |
| CaptionDataField="SessionLapID"> | |
| <FormTableItemStyle Width="100%" Height="29px" /> | |
| <FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2" /> | |
| <FormStyle Width="100%" BackColor="#eef2ea" /> | |
| <EditColumn ButtonType="ImageButton" /> | |
| </EditFormSettings> | |
| </MasterTableView> | |
| </telerik:RadGrid> | |
| </NestedViewTemplate> |
Here is a snippet of the code from my code behind:
| protected void rgRaceDaySessions_ItemCreated(object sender, GridItemEventArgs e) { | |
| if (e.Item.ItemType == GridItemType.NestedView) { | |
| // Bind grid that shows Laps. | |
| RadGrid gridLaps = (RadGrid)e.Item.FindControl("rgLaps"); | |
| Label lbl = (Label)e.Item.FindControl("lblSessionID"); | |
| Label lblRace = (Label)e.Item.FindControl("lblRaceDayID"); | |
| int sessionID = Utils.GetInteger(lbl.Text); | |
| int raceID = Utils.GetInteger(lblRace.Text); | |
| if (sessionID > 0) { | |
| // Bind grid in nested view to data for SessionID being bound in Main View. | |
| } | |
| } | |
| } |
Again, I do not want to use a DataSource server control in the ASPX page to do this binding.
