I have a radgrid and I can loo through the selected items. If I set the for loop
for (int i = 0; i < totalSelected; i++) GridDataItem selectedItem = (GridDataItem) RadGrid1.SelectedItems[i]it will loop in the order that they were selected and not the order of display on the screen. Is there a way to loop through the selected based on the order in the grid?
for the time being I have found
foreach (GridDataItem item in RadGrid1.MasterTableView.Items){ if (item.Selected) {but this will loop through the whole grid which seems kind of a waist when I should be able to just loop through the selected items.

I have a page that has a RadGrid with a Context Menu on it. I am using the context menu to fire open a RadWindow that is hosting another aspx page with a RadProgressArea completing a long running process. Once the job is finished I have some JS in a placeholder that I make visable to Rebind the radgrid and then close the RadWindow.
Everything works fine except if I rebind the RadGrid the RadWindow reopens back up. What am I doing wrong?
Here is the main aspx page - stripped down to be simple.
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="PartInventory.ascx.vb" Inherits="UserControls_PartInventory" %><telerik:RadCodeBlock runat="server" ID="RadCodeBlock2"> <script type="text/javascript"> function RowContextMenu(sender, eventArgs) { var menu = $find("<%=RadMenu1.ClientID %>"); var evt = eventArgs.get_domEvent(); if (evt.target.tagName == "INPUT" || evt.target.tagName == "A") { return; } var index = eventArgs.get_itemIndexHierarchical(); document.getElementById("radGridClickedRowIndex").value = index; sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true); menu.show(evt); evt.cancelBubble = true; evt.returnValue = false; if (evt.stopPropagation) { evt.stopPropagation(); evt.preventDefault(); } } function refreshGrid() { var masterTable = $find("<%=rgInventoryEdit.ClientID%>").get_masterTableView(); masterTable.rebind(); } </script> </telerik:RadCodeBlock><telerik:RadGrid ID="rgInventoryEdit" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" CellSpacing="0" DataSourceID="sqlInventory" GridLines="None" Skin="WebBlue" AllowMultiRowSelection="true" AllowAutomaticDeletes="True" > <ClientSettings> <ClientEvents OnRowContextMenu="RowContextMenu" /> <Selecting CellSelectionMode="None" AllowRowSelect="True"></Selecting> <Resizing AllowColumnResize="True" AllowResizeToFit="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="True"></Resizing> </ClientSettings> <MasterTableView AutoGenerateColumns="False" DataKeyNames="InventoryID" DataSourceID="sqlInventory" PageSize="25" ShowFooter="True" ShowHeader="true" CommandItemDisplay="Top"> <CommandItemTemplate> <div style="padding: 5px 5px;"> <asp:LinkButton ID="LinkButton1" runat="server" OnClick="SaveGridSettings" CommandName="SaveSettings"><img style="border:0px;vertical-align:middle;" alt="" src="../../Images/Icons/24x24/save24x24.png"/> Save Layout</asp:LinkButton> </div> </CommandItemTemplate> <Columns> <telerik:GridTemplateColumn HeaderText="Img" AllowFiltering="False" UniqueName="HasImages"> <HeaderStyle Width="35px"></HeaderStyle> <ItemStyle Width="35px"></ItemStyle> <ItemTemplate> <asp:HyperLink ID="HyperLink1" runat="server" Text="Link" Target="_blank" Visible='<%# Eval("HasImages")%>' ImageUrl="~/Images/BlueIcons/16x16/blue16_032.gif" onclick="window.open (this.href, 'child', 'height=800,width=800,scrollbars'); return false" NavigateUrl='<%# String.Format("~/CarAndPartPics.aspx?NoMaster=True&InventoryNumber={0}&StockNumber={1}", Convert.ToString(Eval("InventoryNumber")), Convert.ToString(Eval("StockTicketNumber")))%>' /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"> <ItemStyle CssClass="MyImageButton" /> </telerik:GridEditCommandColumn> <telerik:GridButtonColumn ConfirmText="Delete this Part?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"> <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> </telerik:GridButtonColumn> </Columns> </MasterTableView></telerik:RadGrid><telerik:RadPersistenceManagerProxy ID="RadPersistenceManagerProxy1" runat="server"> <PersistenceSettings> <telerik:PersistenceSetting ControlID="rgInventoryEdit" /> </PersistenceSettings></telerik:RadPersistenceManagerProxy><input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex" /><telerik:RadContextMenu ID="RadMenu1" runat="server" OnItemClick="RadMenu1_ItemClick" SkinID="WebBlue" EnableRoundedCorners="true" EnableShadows="true"> <Items> <telerik:RadMenuItem Text="Increase Prices"> </telerik:RadMenuItem> <telerik:RadMenuItem Text="Do Multiple Operations"> </telerik:RadMenuItem> </Items> </telerik:RadContextMenu><telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false" ReloadOnShow="true" runat="server" EnableShadow="true"> <Windows> <telerik:RadWindow ID="rwOne" runat="server" ReloadOnShow="true" ShowContentDuringLoad="false" Behaviors="Close,Move" Modal="true" > </telerik:RadWindow> </Windows></telerik:RadWindowManager><asp:SqlDataSource ID="sqlInventory" runat="server" ConnectionString="<%$ ConnectionStrings: %>" </asp:SqlDataSource>Imports Telerik.Web.UIPartial Class UserControls_PartInventory Inherits System.Web.UI.UserControl Protected Sub UserControls_PartInventory_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then LoadTelerikPF() End If End Sub Public Function SaveTelerikPF() As Boolean Try Dim mstr As MasterPage = Me.Parent.Page.Master Dim rp As Telerik.Web.UI.RadPersistenceManager = mstr.FindControl("RadPersistenceManager1") rp.SaveState() Catch ex As Exception Return False End Try Return True End Function Public Function LoadTelerikPF() As Boolean Try Dim mstr As MasterPage = Me.Parent.Page.Master Dim rp As Telerik.Web.UI.RadPersistenceManager = mstr.FindControl("RadPersistenceManager1") rp.LoadState() Catch ex As Exception Return False End Try Return True End Function Protected Sub SaveGridSettings(sender As Object, e As EventArgs) SaveTelerikPF() End Sub Protected Sub RadMenu1_ItemClick(sender As Object, e As Telerik.Web.UI.RadMenuEventArgs) Handles RadMenu1.ItemClick Dim intArray(rgInventoryEdit.SelectedItems.Count - 1) As Integer Dim intCount As Integer = 0 For Each row As GridItem In rgInventoryEdit.SelectedItems intArray(intCount) = rgInventoryEdit.MasterTableView.Items(row.ItemIndex).GetDataKeyValue("InventoryID") intCount += 1 Next Dim strGUID As String = Guid.NewGuid.ToString Session(strGUID) = intArray Select Case e.Item.Text Case "Increase Prices" RadWindowManager1.Windows(0).Title = "Increase Prices" RadWindowManager1.Windows(0).Height = 300 RadWindowManager1.Windows(0).Width = 600 RadWindowManager1.Windows(0).Left = 150 RadWindowManager1.Windows(0).NavigateUrl = "~/UserControls/PartEditDialogs/IncreasePrice.aspx?sesKey=" + Server.HtmlEncode(strGUID) RadWindowManager1.Windows(0).VisibleOnPageLoad = True Case "Do Multiple Operations" End Select End SubEnd Class<%@ Page Language="VB" AutoEventWireup="false" CodeFile="IncreasePrice.aspx.vb" Inherits="UserControls_PartEditDialogs_IncreasePrice" Theme="SkinFile" StylesheetTheme="SkinFile" %><style type="text/css"> .auto-style1 { width: 348px; }</style><telerik:RadCodeBlock runat="server" ID="RadCodeBlock2"> <script type="text/javascript">function GetRadWindow() { var oWindow = null; if (window.radWindow) oWindow = window.radWindow; else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; return oWindow; } </script> </telerik:RadCodeBlock><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server" AsyncPostBackTimeout="3600"/> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1"> </telerik:RadAjaxManager> <telerik:RadProgressManager ID="RadProgressManager1" Runat="server" /> <div> <table> <tr> <td style="text-align: right"> <asp:Label ID="Label1" runat="server" SkinID="stdLabel" Text="Amount to add to Retail :"></asp:Label> </td> <td> <asp:TextBox ID="tbRetail" runat="server" Width="50px">0</asp:TextBox> </td> <td class="auto-style1"> <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="tbRetail" ErrorMessage="Please enter an amount between 0 and 1000" MaximumValue="1000" MinimumValue=".01"></asp:RangeValidator> </td> </tr> <tr> <td style="text-align: right"> <asp:Label ID="Label2" runat="server" SkinID="stdLabel" Text="Amount to add to Wholesale :"></asp:Label> </td> <td> <asp:TextBox ID="tbWholesale" runat="server" Width="50px">0</asp:TextBox> </td> <td class="auto-style1"> <asp:RangeValidator ID="RangeValidator2" runat="server" ControlToValidate="tbWholesale" ErrorMessage="Please enter an amount between 0 and 1000" MaximumValue="1000" MinimumValue=".01"></asp:RangeValidator> </td> </tr> <tr> <td style="text-align: right"> <asp:Button ID="btnSetPrices" runat="server" Text="Adjust Prices" /> </td> <td> </td> <td class="auto-style1"> </td> </tr> </table> </div> <asp:PlaceHolder ID="phCloseWindow" runat="server"> <script> var oWin = GetRadWindow(); var parentWindow = oWin.BrowserWindow; oWin.close(); parentWindow.refreshGrid(); </script> </asp:PlaceHolder> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Width="600px" Height="300px" Runat="server" IsSticky="True" MinDisplayTime="1000" Skin="Default"> </telerik:RadAjaxLoadingPanel> <div style="position:absolute;z-index:1000;top:10px;left:10px"> <telerik:RadProgressArea ID="RadProgressArea1" runat="server" Skin="WebBlue" HeaderText="Current Progress" ProgressIndicators="FilesCountBar, CurrentFileName, TimeElapsed"> <Localization Uploaded="Uploaded" CurrentFileName="" UploadedFiles=""></Localization> </telerik:RadProgressArea> </div> </form></body></html>Imports Telerik.Web.UIImports System.ThreadingPartial Class UserControls_PartEditDialogs_IncreasePrice Inherits System.Web.UI.Page Protected Sub UserControls_PartEditDialogs_IncreasePrice_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then phCloseWindow.Visible = False End If End Sub Protected Sub btnSetPrices_Click(sender As Object, e As EventArgs) Handles btnSetPrices.Click Dim sesKey As String = Request.QueryString("sesKey") Dim invArray As Integer() = Session(sesKey) Dim bolSuccess As Boolean = True Dim strWarning As String = "" For Each intID As Integer In invArray Label1.Text += intID.ToString + vbCrLf Next Dim progress As RadProgressContext = RadProgressContext.Current progress.Speed = "N/A" progress.CurrentOperationText = "Part 1 of " + invArray.Count.ToString RadProgressArea1.Localization.CurrentFileName = "Re-Pricing Parts : " progress.OperationComplete = False Dim intProgress As Integer = 0 For Each intInventoryID As Integer In invArray Thread.Sleep(1000) intProgress += 1 progress.TimeEstimated = (invArray.Count - intProgress) * 100 progress.CurrentOperationText = "Part " + intProgress.ToString() + " of " + invArray.Count.ToString Next phCloseWindow.Visible = bolSuccess progress.OperationComplete = True End SubEnd ClassIf Not IsPostBack Then For Each button As RadToolBarButton In radtoolMonths.Items button.AllowSelfUnCheck = True button.CheckOnClick = True button.PostBack = True NextEnd Ifhi,
I have created a UserControl to display the data using RadListView. I am loading this user Control dynamically in a webpage.
List is displayed properly and all the data is shown correctly. When user clicks on the edit link, it is able to go into edit mode. But when user clicks on the update button, it doesn't fire the Item Command event handler. It just closes the edit view and nothing is saved. When the control is loaded dynamically, should I have to register the event handlers again? In my case the Edit item template is a custom layout and button is inside the layout. Can you help to solve this issue?
<EditItemTemplate> <table cellspacing="0" cellpadding="0" style="width: 100%" border="0"> <tr> <td colspan="2" align="right"> <asp:LinkButton ID="UpdatePropertiesButton" runat="server" Text="Update" CommandName="Update" ></asp:LinkButton> <asp:LinkButton ID="BtnCancel" runat="server" Text="Cancel" CommandName="Cancel" CausesValidation="False"></asp:LinkButton> </td> </tr>
</table></EditItemTemplate>
