Hi,
I have two editbuttons in my gridview, I my form template I have 4 dropdowns.
When I click add new record button all the 4 dropdowns controls should be enable to add a record.
when I click the edit button 1 (Command name is EditEmp) dropdown 1 & dropdown 2 should be enabled and dropdown 3 & dropdown 4 should be disabled to update the record
when I click the edit button 2 (Command name is EditDependent) on the same grid dropdown 1 & dropdown 2 should be disabled and dropdown 3 & dropdown 4 should be enabled to update the record.
Kindly let me know on which event I will do this changes.
thanks,
Ganeshkumar
I found that when I select many files (e.g. around 400 jpg, 6KB per files) in AsyncUpload, the upload speed would become slower and slower. Initially, the upload speed could have around 2.4KB/s, but it gradually drops to even below 40 Bytes per second as the upload proceeds. It takes me so long time to upload a large amount of files.
Are there any configurations to improve the upload speed of multiple files ?
Thanks!
We have an update panel on the page that contains rows of controls. The user can add additional rows or remove existing ones using a button that performs an Ajax postback. If the user adds additional rows, the values of the RadComboBox remain and life is good. However, if the user removes a row, the combobox value is lost (the items are there, but the selected index is set to -1).
In stepping through the code, I can see that the values are indeed set after Page_Load and Page_PreRender, but when the page is finally displayed, the values have been removed.
I've searched high and low and it appears this is an issue others have experienced as well (http://www.telerik.com/forums/selectedvalue-lost-on-postback-in-dynamically-added-user-controls). Unfortunately, I can't bind the values in Page_Init (as suggested in the post) as I need information from ViewState that isn't available until Page_Load.
All other controls on the update panel retain their value; it's *only* the comboboxes that lose theirs.
Has anyone else experienced this lately and, if so, what was the workaround?
We're using Telerik 2014 Q2 in VS2015 (C#).

I cannot seem to use jQuery to select a CheckBoxList inside a RadWindow ContentTemplate.Clicking on the checkboxes does nothing, but if I move the CheckBoxList out of the RadWindow it works fine. I've probably tried a dozen selectors, none work.
<telerik:RadWindow ID="MonthsWindow" runat="server" Skin="Metro" AutoSize="true" MinWidth="575px" MaxWidth="700px" MaxHeight="600px" KeepInScreenBounds="true" Left="100" Top="100" VisibleOnPageLoad="false" Behaviors="Close, Move" RenderMode="auto" DestroyOnClose="true" EnableAjaxSkinRendering="true" ShowContentDuringLoad="true"><ContentTemplate><asp:CheckBoxList ID="CheckBoxList1" runat="Server"> <asp:ListItem Text="Red" Value="red"></asp:ListItem> <asp:ListItem Text="Blue" Value="blue"></asp:ListItem> <asp:ListItem Text="Green" Value="green"></asp:ListItem></asp:CheckBoxList> </ContentTemplate></telerik:RadWindow>$("[id*='CheckBoxList1']").click(function () { //code});<telerik:RadScriptManager runat="server" EnableViewState="false" ID="RadScriptManager1" /> <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript"> function ShowEditForm(id, rowIndex) { var anneeID = 0; var typeRessID = 0; var grid = $find("<%= RadGrid1.ClientID %>"); var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element(); anneeID = document.getElementById("<%= cboAnnees.ClientID %>").value; if (document.getElementById("rbResident").checked == true) { typeRessID = 1; } if (document.getElementById("rbExterne").checked == true) { typeRessID = 2; } if (document.getElementById("rbAutre").checked == true) { typeRessID = 3; } grid.get_masterTableView().selectItem(rowControl, true); window.radopen("UpdateInfo.aspx?ID=" + id + "&TYPERESSID=" + typeRessID + "&ANNEEID=" + anneeID, "UserListDialog"); return false; } function ShowInsertForm() { window.radopen("UpdateRessourceFrameset.aspx", "UserListDialog"); return false; } function refreshGrid(arg) { if (!arg) { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); } else { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate"); } } </script> </telerik:RadCodeBlock> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager><telerik:RadGrid OnItemCreated="RadGrid1_ItemCreated" ID="RadGrid1" runat="server" AllowPaging="True" EnableViewState="true" Width="97%"> <PagerStyle Mode="NumericPages"></PagerStyle> <MasterTableView pagesEnableViewState="true" AutoGenerateColumns="False" DataKeyNames="RESS_ID" ShowHeadersWhenNoRecords="false" ClientDataKeyNames="RESS_ID" Width="100%" PageSize="20"> <Columns> <telerik:GridBoundColumn DataField="INFO2" HeaderText="Year" ReadOnly="True"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="INFO1" HeaderText="Name"/> <telerik:GridTemplateColumn UniqueName="TemplateEditColumn"> <ItemTemplate> <asp:HyperLink ID="EditLink" runat="server" Text="Edit"></asp:HyperLink> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> <CommandItemTemplate> <a href="#" onclick="return ShowInsertForm();">No records...</a> </CommandItemTemplate> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="false"></Selecting> </ClientSettings> </telerik:RadGrid> <telerik:RadWindowManager ID="RadWindowManager1" EnableViewState="False" runat="server"> <Windows> <telerik:RadWindow ID="UserListDialog" runat="server" Title="Editer une ressource" Height="500px" Width="930px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true"> </telerik:RadWindow> </Windows> </telerik:RadWindowManager>Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest If e.Argument = "Rebind" Then RadGrid1.MasterTableView.SortExpressions.Clear() RadGrid1.MasterTableView.GroupByExpressions.Clear() RadGrid1.Rebind() ElseIf e.Argument = "RebindAndNavigate" Then RadGrid1.MasterTableView.SortExpressions.Clear() RadGrid1.MasterTableView.GroupByExpressions.Clear() RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1 RadGrid1.Rebind() End If End Sub Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) If TypeOf e.Item Is GridDataItem Then Dim editLink As HyperLink = DirectCast(e.Item.FindControl("EditLink"), HyperLink) editLink.Attributes("href") = "#" editLink.Attributes("onclick") = [String].Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("RESS_ID"), e.Item.ItemIndex) End If End Sub<script type="text/javascript"> function CloseAndRebind(args) { GetRadWindow().BrowserWindow.refreshGrid(args); GetRadWindow().close(); } function GetRadWindow() { var oWindow = null; if (window.radWindow) oWindow = window.radWindow; else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; return oWindow; } function CancelEdit() { window.UserListDialog.close(); } </script>....<asp:ScriptManager id="smUpdateRess" runat="server" /><asp:DetailsView runat="server" ID="DetailsView1" OnItemUpdating="DetailsView1_ItemUpdating" AutoGenerateEditButton="false" AutoGenerateRows="false" GridLines="None"> <Fields> <asp:TemplateField> <EditItemTemplate> <asp:Button ID="btAddContact" runat="server" Text="Save Contact" CommandName="Update" /> <table border =0 style="width:750px"> <tr> <td style="height: 31px" colspan=4> <asp:Label id="lblInfo1" runat="server" Text="Year: "></asp:Label> <asp:TextBox id="txtInfo2" runat="server" Width="70px" ReadOnly="true" BackColor="LightGray" Text='<%# Container.DataItem("Info2") %>'></asp:TextBox> <asp:Label id="lblinfo2" runat="server" Text="Name:"></asp:Label> <asp:TextBox ID="txtInfo1" runat="server" Width="70px" ReadOnly="true" BackColor="LightGray" Text='<%# Container.DataItem("INFO1") %>'></asp:TextBox> </td> </tr> </table> </EditItemTemplate> </asp:TemplateField> </Fields> </asp:DetailsView>on button clickClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CancelEdit();", True)rwindow.frameElement.radWindowGood morning Telerik Team,
In our application, we disabled Telerik stylesheet CDN and enabled stylesheet combined in the stylesmanager. When we open a page with RadMenu control, the menu mess up and we found one webresource throw 500 error. Is there any setting we need set?
/Telerik.Web.UI.WebResource.axd?d=C6CXK_NKqeRQozdHamsVHY4iEh2-WHZ0hR2lZ4lb0QXhxNgPaCKJi-mbpKFkZJFyaLS96jrWiH-vS8d1mRcnCLyJDy45wzq4xT8qZIVpH1iN6XQB3Ms8R0ovsOLLDEf275IHDg2&t=635025536200000000&compress=1&_TSM_CombinedScripts_=%3b%3bTelerik.Web.UI%2c+Version%3d2015.3.930.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3af59d7c8d-045a-4b22-9f9c-e124aae8c608%3a92753c09%3a91f742eb%3aed2942d4%3a8cee9284%3aed057d30%3aa3b7d93f%3a1f65231b%3a7f7626a2%3a9e1572d6%3ae25b4b77%3a45085116
Thanks in advance,
Lan

<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted" OnItemUpdated="RadGrid1_ItemUpdated" GridLines="None" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"> <GroupingSettings CaseSensitive="False"></GroupingSettings> <ClientSettings AllowColumnsReorder="True"> <Selecting AllowRowSelect="True" /> <Selecting AllowRowSelect="True"></Selecting> </ClientSettings> <GroupingSettings CaseSensitive="false" /> <MasterTableView autogeneratecolumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1"> <Columns> <telerik:GridEditCommandColumn ButtonType="PushButton"> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn DataField="s_page" DefaultInsertValue="" HeaderText="s_page" UniqueName="s_page" SortExpression="s_page"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="s_doc_title" DefaultInsertValue="" HeaderText="s_doc_title" UniqueName="s_doc_title" SortExpression="s_doc_title"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="s_doc_url" DefaultInsertValue="" HeaderText="s_doc_url" SortExpression="s_doc_url" UniqueName="s_doc_url"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="d_date_uploaded" DataType="System.DateTime" DefaultInsertValue="" HeaderText="d_date_uploaded" SortExpression="d_date_uploaded" UniqueName="d_date_uploaded"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="d_date_displayed" DataType="System.DateTime" DefaultInsertValue="" HeaderText="d_date_displayed" SortExpression="d_date_displayed" UniqueName="d_date_displayed"> </telerik:GridBoundColumn> <telerik:GridCheckBoxColumn DataField="b_visible" DefaultInsertValue="" HeaderText="b_visible" UniqueName="b_visible" DataType="System.Boolean" SortExpression="b_visible"> </telerik:GridCheckBoxColumn> </Columns> <EditFormSettings ColumnNumber="3" CaptionFormatString="Edit details for {0}" CaptionDataField="id" EditColumn-ButtonType="PushButton" EditFormType="Template"> <FormTableItemStyle Wrap="False"></FormTableItemStyle> <FormTableStyle CellPadding="2" CellSpacing="0" GridLines="Horizontal" CssClass="module" Height="110px" Width="100%"></FormTableStyle> <FormMainTableStyle CellPadding="3" CellSpacing="0" Width="100%"></FormMainTableStyle> <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle> <FormMainTableStyle GridLines="None" 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" ButtonType="PushButton"> </EditColumn> <FormTableButtonRowStyle HorizontalAlign="Left" CssClass="EditFormButtonRow"></FormTableButtonRowStyle> <FormTemplate> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td width="400"> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td width="5"> </td> <td width="375" valign="top"> ID: </td> <td> <asp:Label ID="lbl_id" runat="server" Text='<%# Bind("id") %>'></asp:Label> </td> </tr> <tr> <td width="5"> </td> <td width="375" valign="top"> Page: </td> <td> <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource3" DataTextField="MenuText" DataValueField="MenuId" SelectedValue='<%# Bind("s_page") %>' Skin="Vista" AutoPostBack="True"> </telerik:RadComboBox> </td> </tr> <tr> <td width="5"> </td> <td width="375" valign="top"> Doc. Title: </td> <td> <asp:TextBox Width="240px" ID="txtbx_title" runat="server" Text='<%# Bind("s_doc_title") %>'></asp:TextBox> </td> </tr> <tr> <td width="5"> </td> <td width="375" valign="top"> Date Uploaded: </td> <td> <asp:TextBox Width="240px" ID="TextBox3" runat="server" Text='<%# Bind("d_date_uploaded") %>'></asp:TextBox> </td> </tr> <tr> <td width="5"> </td> <td width="375" valign="top"> Date Displayed: </td> <td> <asp:TextBox Width="240px" ID="TextBox4" runat="server" Text='<%# Bind("d_date_displayed") %>'></asp:TextBox> </td> </tr> </table> </td> <td width="400"> <table> <tr> <td width="5"> </td> <td width="90" valign="top"> PDF File Name: </td> <td> <asp:TextBox Width="240px" ID="TextBox2" runat="server" Text='<%# Bind("s_doc_url") %>'></asp:TextBox> <asp:Button ID="btn_pdf_upload" runat="server" Text="Upload PDF File" onclick="btn_pdf_upload_Click" /> </td> </tr> </table> </td> </tr> <tr> <td colspan="2" align="center"> <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'> </asp:Button> <asp:Button ID="Button2" runat="server" Text="Cancel" CausesValidation="false" CommandName="Cancel"></asp:Button> </td> </tr> </table> </FormTemplate> </EditFormSettings> <PagerStyle Position="TopAndBottom" /> </MasterTableView> </telerik:RadGrid> <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:SugarSandsConnectionString %>" SelectCommand="SELECT [MenuId], [MenuText] FROM [tbl_menu] ORDER BY [MenuText]"></asp:SqlDataSource> <br /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SugarSandsConnectionString %>" SelectCommand="SELECT * FROM [tbl_pdf_docs] ORDER BY [s_page]" DeleteCommand="DELETE FROM [tbl_pdf_docs] WHERE [id] = @id" InsertCommand="INSERT INTO [tbl_pdf_docs] ([s_page], [s_doc_title], [s_link_title], [s_doc_url], [d_date_uploaded], [d_date_displayed], [b_visible]) VALUES (@s_page, @s_doc_title, @s_link_title, @s_doc_url, @d_date_uploaded, @d_date_displayed, @b_visible)" UpdateCommand="UPDATE [tbl_pdf_docs] SET [s_page] = @s_page, [s_doc_title] = @s_doc_title, [s_doc_url] = @s_doc_url, [d_date_uploaded] = @d_date_uploaded, [d_date_displayed] = @d_date_displayed, [b_visible] = @b_visible WHERE [id] = @id"> <DeleteParameters> <asp:Parameter Name="id" Type="Int32" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="s_page" Type="String" /> <asp:Parameter Name="s_doc_title" Type="String" /> <asp:Parameter Name="s_doc_url" Type="String" /> <asp:Parameter Name="d_date_uploaded" Type="DateTime" /> <asp:Parameter Name="d_date_displayed" Type="DateTime" /> <asp:Parameter Name="b_visible" Type="Boolean" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="s_page" Type="String" /> <asp:Parameter Name="s_doc_title" Type="String" /> <asp:Parameter Name="s_doc_url" Type="String" /> <asp:Parameter Name="d_date_uploaded" Type="DateTime" /> <asp:Parameter Name="d_date_displayed" Type="DateTime" /> <asp:Parameter Name="b_visible" Type="Boolean" /> <asp:Parameter Name="id" Type="Int32" /> </UpdateParameters> </asp:SqlDataSource> </td> </tr> <telerik:RadAjaxManager runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="SqlDataSource1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> <telerik:AjaxUpdatedControl ControlID="SqlDataSource1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager>protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e) { if (e.Exception != null) { e.KeepInEditMode = true; e.ExceptionHandled = true; DisplayMessage(true, "Title " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["s_doc_title"] + " cannot be updated. Reason: " + e.Exception.Message); } else { DisplayMessage(false, "Title " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["s_doc_title"] + " updated"); } } protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e) { if (e.Exception != null) { e.ExceptionHandled = true; e.KeepInInsertMode = true; DisplayMessage(true, "Title cannot be inserted. Reason: " + e.Exception.Message); } else { DisplayMessage(false, "Title inserted"); } } protected void RadGrid1_ItemDeleted(object source, GridDeletedEventArgs e) { if (e.Exception != null) { e.ExceptionHandled = true; DisplayMessage(true, "Title " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["s_doc_title"] + " cannot be deleted. Reason: " + e.Exception.Message); } else { DisplayMessage(false, "Title " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["s_doc_title"] + " deleted"); } } private void DisplayMessage(bool isError, string text) { Label label = (isError) ? this.Label1 : this.Label2; label.Text = text; } private static DataTable tblData = new DataTable(); protected void Page_Load(object sender, System.EventArgs e) { } //protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) //{ // if (e.CommandName == "Update") // { // GridEditFormItem gridEditFormItem = (GridEditFormItem)e.Item; // Label label = (Label)gridEditFormItem.FindControl("lbl_id"); // TextBox textboxPage = (TextBox)gridEditFormItem.FindControl("s_page"); // TextBox textboxDocTitle = (TextBox)gridEditFormItem.FindControl("s_doc_title"); // TextBox textboxLinkTitle = (TextBox)gridEditFormItem.FindControl("s_link_title"); // TextBox textboxDocUrl = (TextBox)gridEditFormItem.FindControl("s_doc_url"); // TextBox textboxDateUp = (TextBox)gridEditFormItem.FindControl("d_date_uploaded"); // TextBox textboxDateDisplay = (TextBox)gridEditFormItem.FindControl("d_date_displayed"); // SqlDataSource1.UpdateCommand = "UPDATE [tbl_pdf_docs] SET [s_page] = @s_page, [s_doc_title] = @s_doc_title, [s_doc_url] = @s_doc_url, [d_date_uploaded] = @d_date_uploaded, [d_date_displayed] = @d_date_displayed WHERE id= @lbl_id"; // SqlDataSource1.Update(); // } // if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked // { // GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); // editColumn.Visible = false; // e.Canceled = true; // e.Item.OwnerTableView.InsertItem(); // GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem(); // TextBox box = insertedItem.FindControl("txt_company_id") as TextBox; // box.Text = Request.QueryString["id"].ToString(); // } // else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) // { // e.Canceled = true; // } // else // { // GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); // if (!editColumn.Visible) // editColumn.Visible = true; // } //} protected void btn_pdf_upload_Click(object sender, EventArgs e) { Response.Redirect("pdf_file_upload.aspx"); } protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { //if (e.Item is GridEditFormItem && e.Item.IsInEditMode) //{ // GridEditFormItem editform = (GridEditFormItem)e.Item; // RadComboBox ddl_menu_items = (RadComboBox)editform.FindControl("RadComboBox1"); // //Populate the dropdownlist // SqlCommand cmd = new SqlCommand("SELECT [MenuId], [MenuText] FROM [tbl_menu] ORDER BY [MenuText]", new SqlConnection(ConfigurationManager.AppSettings["SugarSandsConnectionString"])); // cmd.Connection.Open(); // SqlDataReader ddlValues; // ddlValues = cmd.ExecuteReader(); // ddl_menu_items.DataSource = ddlValues; // ddl_menu_items.DataValueField = "MenuId"; // ddl_menu_items.DataTextField = "MenuText"; // ddl_menu_items.DataBind(); // cmd.Connection.Close(); // cmd.Connection.Dispose(); //} }...<telerik:RadAjaxManager runat="server" ID="radAjaxManager" EnableAJAX="true" OnAjaxRequest="RadAjaxManager_AjaxRequest"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="radAjaxManager"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="radGrid1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings></telerik:RadAjaxManager>...<telerik:RadGrid ID="radGrid1" runat="server" AllowFilteringByColumn="false" AllowPaging="false" AllowSorting="true" AutoGenerateColumns="false" EnableEmbeddedSkins="false" GroupingEnabled="true" OnItemCommand="radGrid1_ItemCommand" OnItemDataBound="radGrid1_ItemDataBound" OnNeedDataSource="radGrid1_NeedDataSource" ShowGroupPanel="false" ShowHeader="true" Skin="XYZ"> <ClientSettings AllowColumnsReorder="true" AllowGroupExpandCollapse="true" AllowDragToGroup="false" ReorderColumnsOnClient="true"> <Resizing AllowColumnResize="false" AllowRowResize="false" EnableRealTimeResize="false" ResizeGridOnColumnResize="false"/> <ClientEvents OnGridCreated="radGrid1_GridCreated" /> </ClientSettings> <MasterTableView AllowMultiColumnSorting="false" DataKeyNames="Data1, Data2" GroupLoadMode="Server" GroupsDefaultExpanded="false" ShowHeader="true" Name="mtvRadGrid1" NoDetailRecordsText="There are no items that match your request." NoMasterRecordsText="There are no items that match your request." ShowFooter="false"> <GroupByExpressions> <telerik:GridGroupByExpression> <SelectFields> <telerik:GridGroupByField Aggregate="First" FieldAlias="Group1NameAlias" FieldName="Group1Name"/> <telerik:GridGroupByField Aggregate="First" FieldAlias="Group1IdAlias" FieldName="Group1Id"/> </SelectFields> <GroupByFields> <telerik:GridGroupByField FieldName="Group1Name" SortOrder="Ascending" /> </GroupByFields> </telerik:GridGroupByExpression> <telerik:GridGroupByExpression> <SelectFields> <telerik:GridGroupByField Aggregate="First" FieldAlias="Group2NameAlias" FieldName="Group2Name"/> <telerik:GridGroupByField Aggregate="First" FieldAlias="Group2IdAlias" FieldName="Group2Id"/> </SelectFields> <GroupByFields> <telerik:GridGroupByField FieldName="Group2Name" SortOrder="Ascending" /> </GroupByFields> </telerik:GridGroupByExpression> </GroupByExpressions> <Columns> <telerik:GridBoundColumn UniqueName="ColumnA" DataField="ColumnA" /> <telerik:GridBoundColumn UniqueName="ColumnB" DataField="ColumnB" /> ... <telerik:GridTemplateColumn UniqueName="link" HeaderText="Link" Groupable="false" SortExpression="sortExpression" HeaderStyle-HorizontalAlign="Left" > <ItemTemplate> <asp:HyperLink ID="itemLink" runat="server"></asp:HyperLink> </ItemTemplate> </telerik:GridTemplateColumn>
... </Columns> </MasterTableView></telerik:RadGrid>protected void radGrid1_ItemDataBound(object source, GridItemEventArgs e){ if (e.Item.ItemType == GridItemType.GroupHeader) { GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item; DataRowView groupDataRow = (DataRowView)e.Item.DataItem; // Telerik does not allow public access to the GroupLevel property of GridItems. // Unfortunately, this is the only way we have found to determine the group level. // The GroupIndex is formatted as "Group1_Group2_Group3" string[] headerItemGroups = e.Item.GroupIndex.Split('_'); string group1Name; string group2Name; int group1Id; int group2Id; int headerItemGroupLevel = headerItemGroups.Length - 1; // GroupLevel is 0 based if (headerItemGroupLevel == 0) { List<int> expandedGroup1IdList = GetSessionExpandedGroup1IdList(); group1Name = groupDataRow["Group1Name"].ToString(); group1Id = (int)groupDataRow["Group1Id"]; // Telerik does not allow access to DataKeyValues in the GridGroupHeaderItems hence the horrible code below. // We can add a group by field to the header, grab it on ItemDataBound, and then replace it with meaningful text item.DataCell.Text = "Group1: " + group1Name; item.Expanded = expandedGroup1IdList.Contains(group1Id); } else if (headerItemGroupLevel == 1) { List<int> expandedGroup2IdList = GetSessionExpandedGroup2IdList(); group2Name = groupDataRow["Group2Name"].ToString(); group2Id = (int)groupDataRow["Group2Id"]; // Telerik does not allow access to DataKeyValues in the GridGroupHeaderItems hence the horrible code below. // We can add a group by field to the header, grab it on ItemDataBound, and then replace it with meaningful text item.DataCell.Text = "Group2: " + group2Name; item.Expanded = expandedGroup2IdList.Contains(group2Id); } } else if (e.Item.ItemType == GridItemType.Item) { Class1 dataItem= (Class1)e.Item.DataItem; HyperLink link = (HyperLink)e.Item.FindControl("itemLink"); if (dataItem.property == ...) { link.NavigateUrl = ... link.Text = ... } else if (dataItem.property == ...) { link.NavigateUrl = ... link.Text = ... } }}protected void radGrid1_ItemCommand(object source, GridCommandEventArgs e){ if (e.CommandName == RadGrid.ExpandCollapseCommandName) { // Telerik does not allow public access to the GroupLevel property of GridItems. // Unfortunately, this is the only way we have found to determine the group level. // The GroupIndex is formatted as "Group1_Group2_Group3" string[] headerItemGroups = e.Item.GroupIndex.Split('_'); string[] dataItemGroups; int group1Id; int group2Id; int headerItemGroupLevel = headerItemGroups.Length - 1; // Group Level is 0 based bool isExpanded = !e.Item.Expanded; // The item is currently expanding/collapsing so the state is yet to change foreach (GridDataItem item in e.Item.OwnerTableView.Items) { dataItemGroups = item.GroupIndex.Split('_'); // Telerik does not provide access to DataKeyValues from GridGroupHeaderItems // Loop through all items in the MasterTableView until we find an item that belongs to the group(s) of the clicked item // Save the appropriate IDs in a session variable to track which items are expanded if (headerItemGroupLevel == 0 && headerItemGroups[0] == dataItemGroups[0]) { group1Id = (int)item.GetDataKeyValue("Group1Id"); SaveSessionExpandedGroup1IdList(group1Id, isExpanded); break; } else if (headerItemGroupLevel == 1 && headerItemGroups[0] == dataItemGroups[0] && headerItemGroups[1] == dataItemGroups[1]) { group2Id = (int)item.GetDataKeyValue("group2Id"); SaveSessionExpandedGroup2IdList(group2Id, isExpanded); break; } } }}