or
ctl00$ctl00$MasterMainContent$MainContent$ucSetupPosition$RadGrid1$ctl00$ctl02$ctl03$RadComboBoxPositionCategoryctl00$ctl00$MasterMainContent$MainContent$ucSetupPosition$RadGrid1$ctl00$ctl11$RadComboBoxPositionCategory<script type="text/javascript"> // Must hard code IDs due to Telerik quirkiness var radComboPosCatID = 'RadComboBoxPositionCategory'; function RadComboBoxSport_SelectedIndexChanged(sender, eventArgs) { var comboSport = eventArgs.get_item(); var comboPosCat = GetRadComboBoxFromPage(radComboPosCatID); if (comboPosCat != null && comboSport.get_value() > 0) { comboPosCat.clearSelection(); // Fire off call to refresh Position Category dropdown comboPosCat.requestItems(comboSport.get_value(), false); // false=clear items } } function RadComboBoxPositionCategory_ItemsRequested(sender, eventArgs) { //TODO: Resolve issue where, if Grid is in Edit mode (vs. insert mode), this method will not fire // and dropdown will not update! var comboPosCat = sender; comboPosCat.set_text(sender.get_items().getItem(0).get_text()); if (sender.get_items().get_count() > 0) { comboPosCat.showDropDown(); } }</script><telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="WebBlue" /><telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1"> <asp:Label id="StatusMessage" runat="server" CssClass="errorText" /> <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="false" Skin="WebBlue" OnNeedDataSource="RadGrid1_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand" OnInsertCommand="RadGrid1_InsertCommand" OnDeleteCommand="RadGrid1_DeleteCommand" OnItemDataBound="RadGrid1_ItemDataBound"> <PagerStyle VerticalAlign="Bottom" Mode="NextPrev" /> <ClientSettings Scrolling-AllowScroll="true" /> <MasterTableView EditMode="PopUp" DataKeyNames="PositionId,SportId,PositionCategoryId" CommandItemDisplay="Top"> <EditFormSettings CaptionFormatString="Edit Position" InsertCaption="Add Position" PopUpSettings-Modal="false" EditColumn-ButtonType="ImageButton" /> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton"> <HeaderStyle Width="30px" /> <ItemStyle Width="30px" HorizontalAlign="Center" /> </telerik:GridEditCommandColumn> <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" ConfirmDialogType="Classic" ConfirmText="Are you sure you want to delete?"> <HeaderStyle Width="30px" /> <ItemStyle Width="30px" HorizontalAlign="Center" /> </telerik:GridButtonColumn> <telerik:GridTemplateColumn UniqueName="Sport" SortExpression="Sport.Name" HeaderText="Sport" DataField="Sport.Name"> <ItemTemplate> <asp:Label ID="lblSport" runat="server" Text='<%# Eval("Sport.Name") %>' /> </ItemTemplate> <EditItemTemplate> <telerik:RadComboBox runat="server" ID="RadComboBoxSport" AutoPostBack="true" OnClientSelectedIndexChanged="RadComboBoxSport_SelectedIndexChanged" /> <asp:RequiredFieldValidator runat="server" ID="rfvSport" ControlToValidate="RadComboBoxSport" InitialValue="Select..." Text="*" /> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn UniqueName="PositionCategory" SortExpression="PositionCategory.CategoryName" HeaderText="Position Category" DataField="PositionCategory.CategoryName"> <ItemTemplate> <asp:Label ID="lblPositionCategory" runat="server" Text='<%# Eval("PositionCategory.CategoryName") %>' /> </ItemTemplate> <EditItemTemplate> <telerik:RadComboBox runat="server" ID="RadComboBoxPositionCategory" EmptyMessage="Select a sport first..." OnClientItemsRequested="RadComboBoxPositionCategory_ItemsRequested" OnItemsRequested="RadComboBoxPositionCategory_ItemsRequested" /> <asp:RequiredFieldValidator runat="server" ID="rfvPositionCategory" ControlToValidate="RadComboBoxPositionCategory" InitialValue="Select..." Text="*" /> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn UniqueName="PositionName" SortExpression="Name" HeaderText="Position Name" DataField="Name"> <ItemTemplate> <div></div> <asp:Label ID="lblPositionName" runat="server" Text='<%# Eval("Name") %>' /> </ItemTemplate> <EditItemTemplate> <asp:TextBox runat="server" ID="txtPositionName" Text='<%# Bind("Name") %>' /> <asp:RequiredFieldValidator runat="server" ID="rfvPositionName" ControlToValidate="txtPositionName" Text="*" /> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn ReadOnly="true" UniqueName="LastUpdatedDate" SortExpression="LastUpdatedDate" HeaderText="Last Updated" DataField="LastUpdatedDate" DataFormatString="{0:g}" AllowSorting="false" /> </Columns> </MasterTableView> </telerik:RadGrid></telerik:RadAjaxPanel>protected void Page_Load(object sender, EventArgs e){}#region Grid Eventsprotected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e){ PositionCollection positions = new PositionCollection(); positions = PositionBuilder.RetrieveList(); RadGrid1.DataSource = positions;}protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e){ try { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { GridEditableItem item = e.Item as GridEditableItem; #region Sport Dropdown // Bind values to Sport dropdown list in edit/insert mode RadComboBox ddlSport = item.FindControl("RadComboBoxSport") as RadComboBox; SetSportOptions(ddlSport); // If in "Add" mode, ItemIndex == -1. We only want to load value in edit mode if (item.ItemIndex != -1) { int sportId = 0; Int32.TryParse(item.OwnerTableView.DataKeyValues[item.ItemIndex]["SportId"].ToString(), out sportId); ddlSport.SelectedValue = sportId.ToString(); #region Position Category Dropdown // Bind values to Position Category dropdown list in edit mode ONLY if sportId is available if (sportId > 0) { RadComboBox ddlPosCats = item.FindControl("RadComboBoxPositionCategory") as RadComboBox; SetPositionCategoryOptions(ddlPosCats, sportId); if (item.ItemIndex != -1) { int postCatid = 0; Int32.TryParse(item.OwnerTableView.DataKeyValues[item.ItemIndex]["PositionCategoryId"].ToString(), out postCatid); ddlPosCats.SelectedValue = postCatid.ToString(); } } #endregion } #endregion } } catch (Exception ex) { StatusMessage.Text = "Error: " + ex.Message; e.Canceled = true; }}protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e){ try { // Clear out status message StatusMessage.Text = String.Empty; // Get the GridEditableItem of the RadGrid GridEditableItem editedItem = e.Item as GridEditableItem; // Get the primary key value using the DataKeyValue int positionId = Convert.ToInt32(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["PositionId"]); string positionName = (editedItem.FindControl("txtPositionName") as TextBox).Text; int sportId = Convert.ToInt32((editedItem.FindControl("RadComboBoxSport") as RadComboBox).SelectedValue); int posCatId = Convert.ToInt32((editedItem.FindControl("RadComboBoxPositionCategory") as RadComboBox).SelectedValue); // Update value in table if (positionId > 0 && !String.IsNullOrEmpty(positionName) && sportId > 0 && posCatId > 0) { if (!PositionBuilder.Update(positionId, positionName, posCatId, sportId, DateTime.UtcNow, Page.UserId)) { StatusMessage.Text = "Unable to update value. Please try again."; e.Canceled = true; } else { StatusMessage.Text = "Successfully updated value!"; } } // Redraw grid RadGrid1.Rebind(); } catch (Exception ex) { StatusMessage.Text = "Unable to update record. Reason: " + ex.Message; e.Canceled = true; }}protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e){ try { // Clear out status message StatusMessage.Text = String.Empty; GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item; string positionName = (insertedItem.FindControl("txtPositionName") as TextBox).Text; int sportId = Convert.ToInt32((insertedItem.FindControl("RadComboBoxSport") as RadComboBox).SelectedValue); int posCatId = Convert.ToInt32((insertedItem.FindControl("RadComboBoxPositionCategory") as RadComboBox).SelectedValue); if (!String.IsNullOrEmpty(positionName) && sportId > 0 && posCatId > 0) { Position newPos = PositionBuilder.Add(positionName, posCatId, sportId, DateTime.Now, Page.UserId, DateTime.Now, Page.UserId); if (newPos.PositionId <= 0) { StatusMessage.Text = "Unable to insert record. Please try again."; e.Canceled = true; } else { StatusMessage.Text = "Successfully inserted record!"; } } } catch (Exception ex) { StatusMessage.Text = "Unable to insert record. Reason: " + ex.Message; e.Canceled = true; }}protected void RadGrid1_DeleteCommand(object source, Telerik.Web.UI.GridCommandEventArgs e){ try { int positionId = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["PositionId"]); //TODO: SOFT DELETE } catch (Exception ex) { StatusMessage.Text = "Unable to delete record. Reason: " + ex.Message; e.Canceled = true; }}#endregion#region ComboBoxprotected void RadComboBoxPositionCategory_ItemsRequested(object source, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e){ try { //e.Text returns the value of the text parameter set on the client-side RadComboBox combo = (RadComboBox)source; combo.Items.Clear(); int sportId = Convert.ToInt32(e.Text); SetPositionCategoryOptions(combo, sportId); } catch { // Do nothing }}#endregion#region Dropdown Helperspublic void SetSportOptions(RadComboBox comboBox){ RadComboBoxItemCollection items = new RadComboBoxItemCollection(comboBox); comboBox.Items.Add(new RadComboBoxItem("Select...", 0.ToString())); try { SportCollection sports = SportBuilder.RetrieveList(String.Empty, "Name ASC"); foreach (Sport sport in sports) { comboBox.Items.Add(new RadComboBoxItem(sport.Name, sport.SportId.ToString())); } } catch { // Do nothing }}private void SetPositionCategoryOptions(RadComboBox comboBox, int sportId){ RadComboBoxItemCollection items = new RadComboBoxItemCollection(comboBox); comboBox.Items.Add(new RadComboBoxItem("Select...", 0.ToString())); comboBox.SelectedValue = 0.ToString(); try { PositionCategoryCollection posCats = PositionCategoryBuilder.RetrieveList( String.Format("SportId={0}",sportId), "CategoryName ASC"); foreach (PositionCategory cat in posCats) { comboBox.Items.Add(new RadComboBoxItem(cat.CategoryName, cat.PositionCategoryId.ToString())); } } catch { // Do nothing }}#endregion<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" height="200px" width="95%"> <telerik:RadComboBox ID="RadComboSearch" Runat="server" AutoPostBack="True" EmptyMessage="Type your search query here;" Height="98%" ShowDropDownOnTextboxClick="True" ShowMoreResultsBox="True" Text="Enter Search Criteria" Width="100%" AllowCustomText="True" EnableVirtualScrolling="True" MarkFirstMatch="True" DataSourceID="MyWebServices" DataValueField="StringResult" DataTextField="StringResult" EnableAutomaticLoadOnDemand="True" ItemsPerRequest="10" > </telerik:RadComboBox> <asp:ObjectDataSource ID="MyWebServices" runat="server" SelectMethod="SearchBoxResult" TypeName="NVSS_Manual.Lookup" > <SelectParameters> <asp:ControlParameter ControlID="RadComboSearch" Name="SearchString" PropertyName="Text" Type="String" /> </SelectParameters> </asp:ObjectDataSource> </telerik:RadAjaxPanel>
The data provider is a method on the page that calls a web service and converts the dataset to a datatable
public DataTable SearchBoxResult(string SearchString){ DataTable ReturnValue = null; NVSS_ManualWebService.NVSS_Manual_WebService ws = new NVSS_ManualWebService.NVSS_Manual_WebService(); DataSet ds =ws.Search_BoxResult(); ReturnValue = ds.Tables[0]; return ReturnValue;}...
[WebMethod] public DataSet Search_BoxResult() { DataSet ds = new DataSet(); DataTable dt = new DataTable(); DataColumn dc=new DataColumn("StringResult", Type.GetType("System.String")); dt.Columns.Add(dc); ds.Tables.Add(dt); dt.Rows.Add("Appendicitus"); dt.Rows.Add("aaa1"); dt.Rows.Add("aaa3"); dt.Rows.Add("aaa2"); return ds; }
... protected void Load_ManualWithFoundContent(string SearchResult) { WebServiceProxy wsp = new WebServiceProxy(); DataSet ManualsWithSearchResults = wsp.GetServicesHandle.Search_ManualTitlesResult(SearchResult); DataTable dt = ManualsWithSearchResults.Tables[0]; DataRowCollection drc = dt.Rows; RadListBoxItemCollection rlbic = RadList_ManualsWithFoundContent.Items; int i = 0; foreach (DataRow dr in drc) { RadListBoxItem rlbi = new RadListBoxItem(dr["ManualName"].ToString(), dr["pKey"].ToString()); rlbi.BackColor = i++ %2 ==0 ? Color.WhiteSmoke : Color.White; rlbic.Add(rlbi); } }function RadList_ManualsWithFoundContent_OnClientMouseOver(sender, evenArgs) { ...???set item color???...
}

<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits="Default" %> <html> <head runat="server"> <title></title> <style type="text/css"> .noAccessCursor, .noAccessCursor * { cursor:url('noaccess.cur'), default !important; } </style> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager" runat="server" /> <telerik:RadScriptBlock runat="server" ID="ScriptBlock"> <script type="text/javascript"> function gridRowContextMenu(sender, args) { // remove the cursor cause but the onrowdragstarted Sys.UI.DomElement.removeCssClass(document.documentElement, "noAccessCursor"); var evt = args.get_domEvent(); if(evt.target.tagName == "INPUT" || evt.target.tagName == "A") return; var menu = $find("<%= ContextMenu1.ClientID %>"); menu.show(evt); //evt.cancelBubble = true; //evt.returnValue = false; //if (evt.stopPropagation) //{ // evt.stopPropagation(); // evt.preventDefault(); //} } var destTaxonomyID; //var expandedNodes = []; function gridRowDropping(sender, args) { args.set_cancel(true); alert("Dropped"); // reset the cursor to default Sys.UI.DomElement.removeCssClass(document.documentElement, "noAccessCursor"); } function gridRowDragStarted(sender, args) { Sys.UI.DomElement.addCssClass(document.documentElement, "noAccessCursor"); } </script> </telerik:RadScriptBlock> <telerik:RadContextMenu ID="ContextMenu1" runat="server" Skin="Vista"> <Items> <telerik:RadMenuItem Text="Menu 1" /> <telerik:RadMenuItem Text="Menu 2" /> </Items> <Targets> <telerik:ContextMenuControlTarget ControlID="GridDocument" /> </Targets> </telerik:RadContextMenu> <telerik:RadGrid ID="Grid1" runat="server" AutoGenerateColumns="False" Skin="Vista" AllowPaging="True" AllowSorting="True" AllowMultiRowSelection="true" GridLines="None" Width="100%" Height="345px" BorderWidth="0px" OnRowDrop="Grid1_RowDrop"> <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" /> <MasterTableView DataKeyNames="ID" ClientDataKeyNames="ID" TableLayout="Fixed"> <Columns> <telerik:GridBoundColumn DataField="Title" HeaderText="Title" UniqueName="Title"> </telerik:GridBoundColumn> </Columns> </MasterTableView> <ClientSettings EnableRowHoverStyle="True" AllowRowsDragDrop="true"> <Selecting AllowRowSelect="True"></Selecting> <ClientEvents OnRowContextMenu="gridRowContextMenu" OnRowDropping="gridRowDropping" OnRowDragStarted="gridRowDragStarted" /> <Scrolling AllowScroll="true" UseStaticHeaders="true" /> <Resizing AllowColumnResize="True" EnableRealTimeResize="true" ClipCellContentOnResize="true"> </Resizing> </ClientSettings> </telerik:RadGrid> </form> </body> </html> using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Configuration; using System.Web.Security; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using Telerik.Web.UI; public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable tb = new DataTable(); tb.Columns.Add("ID"); tb.Columns.Add("Title"); for (int i = 0; i < 10; i++) { DataRow row = tb.NewRow(); row["ID"] = i; row["Title"] = "Title " + i; tb.Rows.Add(row); } Grid1.DataSource = tb; Grid1.DataBind(); } } protected void Grid1_RowDrop(object sender, GridDragDropEventArgs e) { } }