or
function OnRowSelectedMP(sender, args) { alert("Row selected"); var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("SelectedMP"); }<telerik:RadGrid runat="server" ID="grd_ManPower_list" PageSize="5" CellSpacing="0" GridLines="None" OnSelectedIndexChanged="grd_ManPower_list_SelectedIndexChanged" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" ClientSettings-ClientEvents-OnRowDblClick="OnRowDblClick" OnNeedDataSource="grd_ManPower_list_NeedDataSource"> <MasterTableView DataKeyNames="id" ClientDataKeyNames="id"> <Columns> <telerik:GridBoundColumn DataField="id" FilterControlAltText="Filter column column" HeaderText="id" UniqueName="column" Visible="False"> <ColumnValidationSettings> <ModelErrorMessage Text="" /> </ColumnValidationSettings> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Code" FilterControlAltText="Filter column1 column" HeaderText="Staff Code" UniqueName="column1"> <ColumnValidationSettings> <ModelErrorMessage Text="" /> </ColumnValidationSettings> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter column2 column" HeaderText="Name" UniqueName="column2"> <ColumnValidationSettings> <ModelErrorMessage Text="" /> </ColumnValidationSettings> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Trade" FilterControlAltText="Filter column3 column" HeaderText="Trade" UniqueName="column3"> <ColumnValidationSettings> <ModelErrorMessage Text="" /> </ColumnValidationSettings> </telerik:GridBoundColumn> </Columns> <PagerStyle Mode="NumericPages" /> </MasterTableView> <ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true"> <ClientEvents OnRowSelected="OnRowSelectedMP" /> <Selecting AllowRowSelect="True" /> <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="2" ScrollHeight="162px" /> </ClientSettings> </telerik:RadGrid><AjaxSettings> <telerik:AjaxSetting AjaxControlID="grd_ManPower_list"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid_prop_add" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="grd_ManPower_list"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="grd_ManPower_list" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings>else if (e.Argument == "SelectedMP") { foreach (GridDataItem item in grd_ManPower_list.SelectedItems) { if (item.Selected) {//// function load the other grid according to the selected item in first grid } } }
| <telerik:RadGrid |
| ID="RadGrid" |
| Width="820" |
| runat="server" |
| AutoGenerateColumns="False" |
| OnNeedDataSource="RadGrid_NeedDataSource" |
| OnDeleteCommand="RadGrid_Command" |
| OnInsertCommand="RadGrid_Command" |
| OnUpdateCommand="RadGrid_Command" |
| GridLines="None" |
| ShowFooter="True" |
| GroupingEnabled="False" |
| Skin="Telerik"> |
| <MasterTableView |
| DataKeyNames="CategoryID" |
| GridLines="None" |
| CommandItemDisplay="Top" |
| NoMasterRecordsText="No Categories have been added."> |
| <CommandItemSettings |
| AddNewRecordText="Add New Category" |
| RefreshText="Refresh Category List" /> |
| <Columns> |
| <telerik:GridButtonColumn |
| CommandName="Delete" |
| Text="Delete" |
| UniqueName="Delete" |
| ButtonType="ImageButton"> |
| </telerik:GridButtonColumn> |
| <telerik:GridBoundColumn |
| DataField="CategoryID" |
| HeaderText="CategoryID" |
| UniqueName="CategoryID" |
| ReadOnly="True"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="CategoryTitle" |
| HeaderText="CategoryTitle" |
| UniqueName="CategoryTitle"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="CategoryDescription" |
| HeaderText="CategoryDescription" |
| UniqueName="CategoryDescription"> |
| </telerik:GridBoundColumn> |
| <telerik:GridEditCommandColumn |
| ButtonType="ImageButton"> |
| </telerik:GridEditCommandColumn> |
| </Columns> |
| <EditFormSettings |
| ColumnNumber="2" |
| CaptionFormatString="Edit details for category with ID {0}" |
| CaptionDataField="CategoryID"> |
| <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 record" |
| UniqueName="EditCommandColumn1" |
| CancelText="Cancel edit"> |
| </EditColumn> |
| <FormTableButtonRowStyle |
| HorizontalAlign="Right" |
| CssClass="EditFormButtonRow"> |
| </FormTableButtonRowStyle> |
| </EditFormSettings> |
| <ExpandCollapseColumn> |
| <HeaderStyle |
| Width="19px"> |
| </HeaderStyle> |
| </ExpandCollapseColumn> |
| <RowIndicatorColumn> |
| <HeaderStyle |
| Width="20px" /> |
| </RowIndicatorColumn> |
| </MasterTableView> |
| <FilterMenu |
| EnableTheming="True"> |
| <CollapseAnimation |
| Duration="200" |
| Type="OutQuint" /> |
| </FilterMenu> |
| </telerik:RadGrid> |
And some of code behind:
| protected void RadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
| { |
| this.categories = new Categories(); |
| this.dataSet = this.categories.Select(); |
| this.RadGrid.DataSource = this.dataSet; |
| } |
Why is it not possible to add a new record when the dataset is empty (null) and why is the no records message not showing? I have insert/update/delete with ReBind working no worries apart from this.
<telerik:RadFormDecorator ID="RadFormDecorator1" ClientIDMode="Static" runat="server" EnableRoundedCorners="true" DecoratedControls="All" ControlsToSkip="H4H5H6, Buttons, Label" />@media screen and (-webkit-min-device-pixel-ratio: 0).RadForm.rfdRadio label, .RadForm.rfdCheckbox label { .... }
<telerik:GridTemplateColumn DataField="pages_body" FilterControlAltText="Filter pages_body column" HeaderText="Pages Body" SortExpression="pages_body" UniqueName="pages_body" Visible="false"> <ItemTemplate> <asp:Label ID="lblField1" CssClass="text" runat="server" Text='<%# Eval("pages_body") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <telerik:RadEditor ID="gridEditor_Body" runat="server" Content='<%# Bind("pages_body") %>' ToolsFile="PagesFile.xml" OnClientCommandExecuting="OnClientCommandExecuting"> <DocumentManager ViewPaths="~/Images/UserFiles" UploadPaths="~/Images/UserFiles" DeletePaths="~/Images/UserFiles" SearchPatterns="*.pdf" MaxUploadFileSize="4096000" /> <ImageManager ViewPaths="~/Images/UserFiles" UploadPaths="~/Images/UserFiles" DeletePaths="~/Images/UserFiles" SearchPatterns="*.gif,*.png,*.jpg" /> </telerik:RadEditor> </EditItemTemplate> </telerik:GridTemplateColumn>

