I'm trying to use a custom user control for inserting and updating data. However, when the use clicks the Add new record link the insert user control is not displayed and the grid is left blank. I think it's because the OnItemCommand event is not firing for some reason. can someone please help?
Here is some code and markup:
The Insert, Update, and Delete events are still empty because I haven't gotten that far. If anyone can take a look and help me out I would greatly appreciate it.
Thank you,
Nick
Here is some code and markup:
| <telerik:RadGrid ID="RadGrid4" runat="server" Skin="WebBlue" Width="95%" |
| AllowPaging="True" AllowSorting="True" |
| OnNeedDataSource="xxxRadGrid1_NeedDataSource" |
| OnUpdateCommand="xxxRadGrid1_UpdateCommand" |
| OnInsertCommand="xxxRadGrid1_InsertCommand" |
| OnDeleteCommand="xxxRadGrid1_DeleteCommand" |
| CommandItemSettings-AddNewRecordText="Add New BMI Measure" |
| OnItemCommand="xxxRadGrid1_ItemCommand" |
| GridLines="Both"> |
| <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> |
| <MasterTableView DataKeyNames="ID" GridLines="Both" Width="100%" |
| CommandItemDisplay="Top" AutoGenerateColumns="False"> |
| <Columns> |
| <telerik:GridEditCommandColumn> |
| </telerik:GridEditCommandColumn> |
| <telerik:GridBoundColumn DataField="ID" HeaderText="" UniqueName="ID" Visible="false"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Height" HeaderText="Height" UniqueName="Height"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Weight" HeaderText="Weight" UniqueName="Weight"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="BMI" HeaderText="BMI" UniqueName="BMI"> |
| </telerik:GridBoundColumn> |
| <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="Delete" ConfirmDialogType="Classic" ConfirmTitle="Deleting BMI Measure" ConfirmText="Are you sure you want to delete the BMI Measure?"> |
| </telerik:GridButtonColumn> |
| </Columns> |
| <EditFormSettings EditFormType="WebUserControl" UserControlName="" ColumnNumber="2" CaptionFormatString="Edit details for the Benchmark" |
| CaptionDataField="ID"> |
| <FormTableItemStyle Wrap="False"></FormTableItemStyle> |
| <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle> |
| <FormMainTableStyle CellSpacing="0" CellPadding="3" Width="100%" /> |
| <FormTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="2" CssClass="module" |
| Height="110px" Width="100%" /> |
| <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> |
| <FormStyle Width="100%" BackColor="#EEF2EA"></FormStyle> |
| <EditColumn UpdateText="Update BMI Measure" UniqueName="EditCommandColumn1" CancelText="Cancel Edit"> |
| </EditColumn> |
| <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle> |
| </EditFormSettings> |
| <ExpandCollapseColumn Visible="False"> |
| <HeaderStyle Width="19px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <RowIndicatorColumn Visible="False"> |
| <HeaderStyle Width="20px" /> |
| </RowIndicatorColumn> |
| </MasterTableView> |
| <FilterMenu Skin="WebBlue" EnableTheming="True"> |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
| </FilterMenu> |
| </telerik:RadGrid> |
| protected void xxxRadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
| { |
| RadGrid4.DataSource = bmiMeasures; |
| RadGrid4.DataMember = "BMIMeasures"; |
| } |
| protected void xxxRadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if( e.CommandName == RadGrid.InitInsertCommandName ) |
| { |
| e.Canceled = true; |
| RadGrid4.EditIndexes.Clear(); |
| e.Item.OwnerTableView.EditFormSettings.UserControlName = "DesktopModules\\GCCPopulationEncounters\\InsertBMIMeasure.ascx"; |
| e.Item.OwnerTableView.InsertItem(); |
| } |
| else if( e.CommandName == RadGrid.EditCommandName ) |
| { |
| e.Item.OwnerTableView.IsItemInserted = false; |
| e.Item.OwnerTableView.EditFormSettings.UserControlName = "DesktopModules\\GCCPopulationEncounters\\EditBMIMeasure.ascx"; |
| } |
| } |
The Insert, Update, and Delete events are still empty because I haven't gotten that far. If anyone can take a look and help me out I would greatly appreciate it.
Thank you,
Nick