Folks,
Using VS2010 with RadControls for ASP.NET AJAX Q2 2012 SP2. I am using below link (the 2nd Grid as a prototype).
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/commanditem/defaultcs.aspx
I would like to highlight last updated row when sorting is enabled. Below codes works (i.e. does highlight the last updated row in current page when sorting is not enabled prior to editing).
protected void RadGrid2_PreRender(object sender, EventArgs e) { if (rowindex > -1) { GridDataItem item = (GridDataItem)RadGrid2.Items[rowindex]; item.Selected = true; rowindex = -1; } } int rowindex = -1;protected void RadGrid2_UpdateCommand(object sender, GridCommandEventArgs e) { GridEditFormItem editItem = (GridEditFormItem)e.Item; rowindex = editItem.ItemIndex; }
But lets see if sorting is enabled (i.e. in Contact Name) and if in edit form, I change the Contact Name from Ann Devon to Beann Devon, after update Beann Devon is not showing in current page ( I assume because sorting is enabled in column Contact Name). Please refer to attached.
Is there any way possible to highlight that updated row if sorting is enabled prior to edit? If not, how about disable sorting prior to edit, after update highlight the row and enable sorting or any other suggestions? My users may sort any column, change that column value and still would like to highlight that row after update.
Thanks for any help.
gc_0620
Dim script As String = "function f(){$find(""" + Me.daypopupwindow.ClientID + """).show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);" ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, True)function openAddWindow() { var oBrowserWnd = getRadWindow().BrowserWindow; setTimeout(function () { oBrowserWnd.radopen(null, "jobpopupwindow"); }, 0); }function closeActiveWindow() { var oWin = getParentRadWindow(); oWin.close(); }function closeThisWindow() { var omanager = GetRadWindowManager(); var ownd = omanager.getWindowByName("jobpopupwindow"); ownd.close(); }<%@ Page Language="VB" AutoEventWireup="false" CodeFile="SeriesUpdate.aspx.vb" Inherits="SeriesUpdate" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server" id="Head1"> <title>Update Series</title></head><body onkeydown="return noBackspace(event)" onload="InitWindow()"> <form id="Itemedit" runat="server"> <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server"> </telerik:RadStyleSheetManager> <telerik:RadSkinManager ID="RadSkinManager1" runat="server"> </telerik:RadSkinManager> <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All" /> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <telerik:RadInputManager ID="RadInputManager1" runat="server"> </telerik:RadInputManager> <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript" src="scripts\editwindow.js"> </script> <script type="text/javascript"> function OnClientClicked(button, args) { if (window.confirm("Are you sure you want to delete this item?")) { button.set_autoPostBack(true); } else { button.set_autoPostBack(false); } } function returnArg() { var oWnd = GetRadWindow(); var UniqueID = document.getElementById("<%= lblUniqueID.ClientID %>").value; oWnd.close(UniqueID); } </script> </telerik:RadCodeBlock> <div> <table> <tr> <td> Reference: </td> <td> <ASP:Textbox ID="txtSeriesCode" runat="server" Width="150px" MaxLength="10" ToolTip="Maximum 10 character reference"> </ASP:Textbox> <Telerik:RadTextbox ID="TextBox1" runat="server"></Telerik:RadTextbox> </td> <td> <asp:Label ID="lblUniqueID" runat="server" Text="" Visible="false"></asp:Label> <asp:Label ID="InjectScript" runat="server" Text=""></asp:Label> </td> <td> <asp:CheckBox ID="chkArchived" runat="server" Text="Archivd" TabIndex="99" /> </td> </tr> <tr> <td> Name: </td> <td> <Telerik:RadTextbox ID="txtName1" runat="server" Width="532px" Text=""> </Telerik:RadTextbox> </td> </tr> </table> </div> <div class="Radbutton-line"> <telerik:RadButton ID="btnSave" runat="server" Text="Save & Close"> </telerik:RadButton> <telerik:RadButton ID="btnCancel" runat="server" Text="Cancel"> </telerik:RadButton> <telerik:RadButton ID="btnDelete" runat="server" Text="Delete" OnClientClicked="return OnClientClicked()"> </telerik:RadButton> </div> </form></body></html>Imports Telerik.Web.UIImports TimeManagerImports RoadsInterfacePartial Class SeriesUpdate Inherits System.Web.UI.Page Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack And Not Page.IsCallback Then Dim intUniqueID As Integer = Request.QueryString("UniqueID") lblUniqueID.Text = intUniqueID Dim strStaff As String = Session("Staff") If String.IsNullOrEmpty(strStaff) Then Response.Redirect("~/default.aspx") End If Dim skn As New Skins skn.setSkin(RadSkinManager1) 'skn.setForm(RadFormDecorator1) Dim itm As New dbItem(Session("ConnectionString")) itm.InitialiseItem(itm) If intUniqueID <> 0 Then ShowItem(itm) End If End If End Sub Public Sub ShowItem(ByRef itm As dbItem) itm.SingleSeries(lblUniqueID.Text, itm) txtName1.Text = itm.Name txtSeriesCode.Text = itm.Number chkArchived.Checked = itm.Archive End Sub Protected Sub btnDelete_Click(sender As Object, e As System.EventArgs) Handles btnDelete.Click Dim itm As New dbItem(Session("ConnectionString")) itm.DeleteSeries(lblUniqueID.Text) InjectScript.Text = "<script type='text/javascript'>CloseAndRebind();</" + "script>" End Sub Protected Sub btnCancel_Click(sender As Object, e As System.EventArgs) Handles btnCancel.Click InjectScript.Text = "<script type='text/javascript'>CloseAndRebind();</" + "script>" End Sub Protected Sub btnSave_Click(sender As Object, e As System.EventArgs) Handles btnSave.Click 'txtName1.Text = "Hello" MsgBox(txtName1.Text) Dim itm As New dbItem(Session("ConnectionString")) itm.InitialiseItem(itm) itm.UniqueID = lblUniqueID.Text itm.Name = txtName1.Text itm.Number = txtSeriesCode.Text itm.Archive = chkArchived.Checked Dim Test As String Test = TextBox1.Text If lblUniqueID.Text <> 0 Then 'Update itm.UpdateSeries(itm) Else 'Insert itm.AddSeries(itm) End If InjectScript.Text = "<script type='text/javascript'>CloseAndRebind();</" + "script>" End Sub Protected Sub chkArchived_CheckedChanged(sender As Object, e As System.EventArgs) Handles chkArchived.CheckedChanged End Sub Protected Sub txtName1_TextChanged(sender As Object, e As System.EventArgs) Handles txtName1.TextChanged MsgBox(txtName1.Text) End SubEnd Class<%@ Page Title="" Language="C#" MasterPageFile="~/nestLeftNav.master" AutoEventWireup="true" CodeBehind="SKUEditor.aspx.cs" Inherits="PriceTag.SKUEditor" EnableEventValidation="false" %><%--<%@ Register TagPrefix="ebtc" Src="~/controls/skuEditor.ascx" TagName="sku" %>--%><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><%@ MasterType VirtualPath="~/nestLeftNav.Master" %><asp:Content ID="Content1" ContentPlaceHolderID="nesthead" runat="server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="nestTopNav" runat="server"></asp:Content><asp:Content ID="Content3" ContentPlaceHolderID="nestLeftNavigation" runat="server"></asp:Content><asp:Content ID="Content4" ContentPlaceHolderID="nestMain" runat="server"> <telerik:RadCodeBlock ID="rcb1" runat="server"> <script type="text/javascript"> var grid; var gridPrint; function GridCreated(sender, args) { grid = sender; } function GridPrintCreated(sender, args) { gridPrint = sender; } function RowClicked(sender, args) { //fetch the order id, product name and unit price values from the grid and set them as text in the combobox' input var cellValues = args.getDataKeyValue("ItemCode") + ", " + args.getDataKeyValue("Description"); var combo = $find("<%= rcmbSKU.ClientID %>"); setTimeout(function () { combo.set_text(cellValues); }, 50); } function RowClickedPrintWithSKU(sender, args) { //fetch the order id, product name and unit price values from the grid and set them as text in the combobox' input var cellValues = args.getDataKeyValue("ItemCode") + ", " + args.getDataKeyValue("Description"); var combo = $find("<%= rcmbPrintWithSKU.ClientID %>"); setTimeout(function () { combo.set_text(cellValues); }, 50); } function ShouldInitiateAjaxRequest(comboText) { //if there are three or more symbols entered, filter the data in the dropdown grid if (comboText.length > 2) { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("LoadFilteredData"); return true; } else { return false; } } function ShouldInitiateAjaxRequestPrint(comboText) { //if there are three or more symbols entered, filter the data in the dropdown grid if (comboText.length > 2) { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("PrintLoadFilteredData"); return true; } else { return false; } } function HandleOpen(sender, args) { var flag = ShouldInitiateAjaxRequest(sender.get_text()); //cancel the dropdown opening if less than three characters are entered in the combobox' input if (!flag) { args.set_cancel(true); } } function HandleOpenPrint(sender, args) { var flag = ShouldInitiateAjaxRequestPrint(sender.get_text()); //cancel the dropdown opening if less than three characters are entered in the combobox' input if (!flag) { args.set_cancel(true); } } function HandleKeyPressed(sender) { var combo = $find(sender.id); combo.showDropDown(); } </script> </telerik:RadCodeBlock> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" RequestQueueSize="3"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="ddlVendor"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="ddlVendorCollections" LoadingPanelID="rajaxLoading" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="ddlVendorCollections"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="txtPriceTagDescr" LoadingPanelID="rajaxLoading" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="rgridCollections"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="pnlSuccess" LoadingPanelID="rajaxLoading" /> <telerik:AjaxUpdatedControl ControlID="pnlError" LoadingPanelID="rajaxLoading" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="rajaxLoading" runat="server"> </telerik:RadAjaxLoadingPanel> <div class="span12"> <div class="page-header"> <h2>SKU Editor</h2> </div> <div class="category-select"> <div class="control-group"> <label class="control-label" for="rcmbSKU">SKU:</label> <div class="controls"> <telerik:RadComboBox ID="rcmbSKU" Width="340px" runat="server" MarkFirstMatch="True" CssClass="SKUCombo" EnableEmbeddedBaseStylesheet="true" EnableEmbeddedSkins="false" AllowCustomText="True" OnClientDropDownOpening="HandleOpen" ExpandAnimation-Type="None" CollapseAnimation-Type="None" DropDownWidth="340px" onkeyup="HandleKeyPressed(this)"> <ItemTemplate> <telerik:RadGrid ID="rgridSKU" Width="325px" runat="server" OnSelectedIndexChanged="rgridSKU_OnSelectedIndexChanged" OnNeedDataSource="rgridSKU_NeedDataSource" EnableEmbeddedBaseStylesheet="true" EnableEmbeddedSkins="true"> <MasterTableView NoMasterRecordsText="" AutoGenerateColumns="False" DataKeyNames="ItemCode, ItemKey, Description" Width="100%" ClientDataKeyNames="ItemCode, ItemKey, Description" TableLayout="Fixed"> <Columns> <telerik:GridBoundColumn HeaderText="SKU" DataField="ItemCode" UniqueName="ItemCode"> <HeaderStyle Width="90px"></HeaderStyle> </telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText="Description" DataField="Description" UniqueName="Description"> <HeaderStyle Width="215px"></HeaderStyle> </telerik:GridBoundColumn> </Columns> </MasterTableView> <ClientSettings> <ClientEvents OnRowClick="RowClicked" OnGridCreated="GridCreated"></ClientEvents> <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="300px"></Scrolling> </ClientSettings> </telerik:RadGrid> </ItemTemplate> <Items> <telerik:RadComboBoxItem runat="server" Text=" "></telerik:RadComboBoxItem> </Items> </telerik:RadComboBox> </div> </div> </div> <div class="category-select"> <div class="control-group"> <label class="control-label" for="ddlVendor">Vendor:</label> <div class="controls"> <asp:DropDownList ID="ddlVendor" runat="server" AutoPostBack="true" onselectedindexchanged="ddlVendor_SelectedIndexChanged" /> </div> </div> </div> <div class="category-select"> <div class="control-group"> <label class="control-label" for="ddlVendorCollections">Vendor Collections:</label> <div class="controls"> <asp:DropDownList ID="ddlVendorCollections" runat="server" AutoPostBack="true" onselectedindexchanged="ddlVendorCollections_SelectedIndexChanged" /> </div> </div> </div> <div class="category-select"> <div class="control-group"> <label class="control-label" for="ddlHeadline">Headline:</label> <div class="controls"> <asp:DropDownList ID="ddlHeadline" runat="server" AutoPostBack="true" /> </div> </div> </div> <div class="category-select"> <div class="control-group"> <label class="control-label" for="txtPriceTagDescr">Price Tag Description: </label> <asp:TextBox ID="txtPriceTagDescr" runat="server"></asp:TextBox> </div> </div> <div class="category-select"> <div class="control-group"> <label class="control-label" for="rcmbSKU">SKU:</label> <div class="controls"> <telerik:RadComboBox ID="RadComboBox1" Width="340px" runat="server" MarkFirstMatch="True" CssClass="SKUCombo" EnableEmbeddedBaseStylesheet="true" EnableEmbeddedSkins="false" AllowCustomText="True" OnClientDropDownOpening="HandleOpen" ExpandAnimation-Type="None" CollapseAnimation-Type="None" DropDownWidth="340px" onkeyup="HandleKeyPressed(this)"> <ItemTemplate> <telerik:RadGrid ID="rgridSKU" Width="325px" runat="server" OnSelectedIndexChanged="rgridSKU_OnSelectedIndexChanged" OnNeedDataSource="rgridSKU_NeedDataSource" EnableEmbeddedBaseStylesheet="true" EnableEmbeddedSkins="true"> <MasterTableView NoMasterRecordsText="" AutoGenerateColumns="False" DataKeyNames="ItemCode, ItemKey, Description" Width="100%" ClientDataKeyNames="ItemCode, ItemKey, Description" TableLayout="Fixed"> <Columns> <telerik:GridBoundColumn HeaderText="SKU" DataField="ItemCode" UniqueName="ItemCode"> <HeaderStyle Width="90px"></HeaderStyle> </telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText="Description" DataField="Description" UniqueName="Description"> <HeaderStyle Width="215px"></HeaderStyle> </telerik:GridBoundColumn> </Columns> </MasterTableView> <ClientSettings> <ClientEvents OnRowClick="RowClicked" OnGridCreated="GridCreated"></ClientEvents> <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="300px"></Scrolling> </ClientSettings> </telerik:RadGrid> </ItemTemplate> <Items> <telerik:RadComboBoxItem runat="server" Text=" "></telerik:RadComboBoxItem> </Items> </telerik:RadComboBox> </div> </div> </div> <div class="category-select"> <div class="control-group"> <label class="control-label" for="rcmbPrintWithSKU">Print with SKU</label> <div class="controls"> <telerik:RadComboBox ID="rcmbPrintWithSKU" Width="340px" runat="server" MarkFirstMatch="True" CssClass="SKUCombo" EnableEmbeddedBaseStylesheet="true" EnableEmbeddedSkins="false" AllowCustomText="True" OnClientDropDownOpening="HandleOpenPrint" ExpandAnimation-Type="None" CollapseAnimation-Type="None" DropDownWidth="340px" onkeyup="HandleKeyPressed(this)"> <ItemTemplate> <telerik:RadGrid ID="rgridPrintWithSKU" Width="325px" runat="server" OnSelectedIndexChanged="rgridPrintWithSKU_OnSelectedIndexChanged" OnNeedDataSource="rgridPrintWithSKU_NeedDataSource" EnableEmbeddedBaseStylesheet="true" EnableEmbeddedSkins="true"> <MasterTableView NoMasterRecordsText="" AutoGenerateColumns="False" DataKeyNames="ItemCode, ItemKey, Description" Width="100%" ClientDataKeyNames="ItemCode, ItemKey, Description" TableLayout="Fixed"> <Columns> <telerik:GridBoundColumn HeaderText="SKU" DataField="ItemCode" UniqueName="ItemCode"> <HeaderStyle Width="90px"></HeaderStyle> </telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText="Description" DataField="Description" UniqueName="Description"> <HeaderStyle Width="215px"></HeaderStyle> </telerik:GridBoundColumn> </Columns> </MasterTableView> <ClientSettings> <ClientEvents OnRowClick="RowClickedPrintWithSKU" OnGridCreated="GridPrintCreated"></ClientEvents> <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="300px"></Scrolling> </ClientSettings> </telerik:RadGrid> </ItemTemplate> <Items> <telerik:RadComboBoxItem runat="server" Text=" "></telerik:RadComboBoxItem> </Items> </telerik:RadComboBox> </div> </div> </div> <div class="category-select"> <div class="control-group"> <div class="controls"> <asp:Button ID="btnSave" runat="server" Text="Button" OnClick="btnSave_OnClick" /> </div> </div> </div> </div></asp:Content>using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;using Telerik.Web.UI;using System.Configuration;using Database;namespace PriceTag{ public partial class SKUEditor : PriceTag.classes.ConlinsBasePage { public Database.VendorCollection _dsVendorCollections { get { if (ViewState["VendorCollection"] != null) { return (Database.VendorCollection)ViewState["VendorCollection"]; } else { return null; } } set { ViewState["VendorCollection"] = value; } } public Header parentMasterPage { get { return (Master.parentMaster as Header); } } protected void Page_Load(object sender, EventArgs e) { RadGrid grid = rcmbSKU.Items[0].FindControl("rgridSKU") as RadGrid; RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadAjaxManager1, grid, rajaxLoading); if (!IsPostBack) { fillVendorDropDown(); fillHeadlineCombo(); } } protected DataTable fillItemSKUCombo() { try { Database.Item ds = new Item(); Database.ItemTableAdapters.ItemTableAdapter ta = new Database.ItemTableAdapters.ItemTableAdapter(); ta.Fill(ds._Item, rcmbSKU.Text); //RadComboBox1.DataSource = ds._Item; //RadComboBox1.DataValueField="ItemCode"; //RadComboBox1.DataBind(); return ds._Item; } catch (Exception ex) { throw new System.Exception("There was an issue" + ex.ToString()); } } protected DataTable fillItemPrintWithSKUCombo() { try { Database.Item ds = new Item(); Database.ItemTableAdapters.ItemTableAdapter ta = new Database.ItemTableAdapters.ItemTableAdapter(); ta.Fill(ds._Item, rcmbPrintWithSKU.Text); //RadComboBox1.DataSource = ds._Item; //RadComboBox1.DataValueField="ItemCode"; //RadComboBox1.DataBind(); return ds._Item; } catch (Exception ex) { throw new System.Exception("There was an issue" + ex.ToString()); } } protected void rgridSKU_NeedDataSource(object source, GridNeedDataSourceEventArgs e) { RadGrid grid = source as RadGrid; if (rcmbSKU.Text != "") { //split the combobox text and filter the records in the grid based on the first value in the array, i.e. OrderID String[] vals = rcmbSKU.Text.Split(','); if (vals.Length > 0) { rcmbSKU.Text = vals[0]; } grid.DataSource = fillItemSKUCombo(); //grid.DataSource = GetDataTable("SELECT [Order Details].OrderID, Products.ProductName, [Order Details].UnitPrice FROM Products, [Order Details] " + //"WHERE [Order Details].OrderID LIKE '" + RadComboBox1.Text + "%'" + " AND Products.ProductID=[Order Details].ProductID"); } else { DataTable dt = new DataTable(); dt.Columns.Add("ItemCode"); dt.Columns.Add("Description"); //dt.Columns.Add("ProductName"); //dt.Columns.Add("UnitPrice"); grid.DataSource = dt; } } protected void rgridPrintWithSKU_NeedDataSource(object source, GridNeedDataSourceEventArgs e) { RadGrid gridPrint = source as RadGrid; if (rcmbPrintWithSKU.Text != "") { //split the combobox text and filter the records in the grid based on the first value in the array, i.e. OrderID String[] vals = rcmbPrintWithSKU.Text.Split(','); if (vals.Length > 0) { rcmbPrintWithSKU.Text = vals[0]; } gridPrint.DataSource = fillItemPrintWithSKUCombo(); //grid.DataSource = GetDataTable("SELECT [Order Details].OrderID, Products.ProductName, [Order Details].UnitPrice FROM Products, [Order Details] " + //"WHERE [Order Details].OrderID LIKE '" + RadComboBox1.Text + "%'" + " AND Products.ProductID=[Order Details].ProductID"); } else { DataTable dt = new DataTable(); dt.Columns.Add("ItemCode"); dt.Columns.Add("Description"); //dt.Columns.Add("ProductName"); //dt.Columns.Add("UnitPrice"); gridPrint.DataSource = dt; } } protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) { RadGrid gridPrint = rcmbPrintWithSKU.Items[0].FindControl("rgridPrintWithSKU") as RadGrid; //detect the filter action if (e.Argument.IndexOf("PrintLoadFilteredData") != -1) { gridPrint.Rebind(); } RadGrid grid = rcmbSKU.Items[0].FindControl("rgridSKU") as RadGrid; //detect the filter action if (e.Argument.IndexOf("LoadFilteredData") != -1) { grid.Rebind(); } } protected void ddlVendor_SelectedIndexChanged(object sender, EventArgs e) { try { fillVendorCollectionDropDown(); searchForItemAttributes(); } catch (Exception ex) { this.parentMasterPage.showError(ex.ToString()); } } protected void ddlVendorCollections_SelectedIndexChanged(object sender, EventArgs e) { try { searchForItemAttributes(); } catch (Exception ex) { this.parentMasterPage.showError("There was an issue when getting the selected Vendor collection value. " + ex.ToString()); } } protected void searchForItemAttributes() { try { string[] strItemCode = rcmbSKU.Text.Split(Convert.ToChar(",")); if (strItemCode.Length > 0) { Database.sp_ItemAttributes_Select ds = new sp_ItemAttributes_Select(); Database.sp_ItemAttributes_SelectTableAdapters.ItemAttributes_SelectTableAdapter ta = new Database.sp_ItemAttributes_SelectTableAdapters.ItemAttributes_SelectTableAdapter(); ta.Fill(ds.ItemAttributes_Select, strItemCode[0], Convert.ToInt32(ddlVendorCollections.SelectedValue.ToString())); if (ds.ItemAttributes_Select.Rows.Count > 0) { txtPriceTagDescr.Text = ds.ItemAttributes_Select.Rows[0]["PriceTagDescription"].ToString(); } } } catch (Exception ex) { throw new System.Exception("There was an issue searching for an existing ItemAttribute. " + ex.ToString()); } } protected void fillVendorCollectionDropDown() { try { string strVendorCode = ddlVendor.SelectedValue.ToString(); Database.sp_VendorCollection_Select ds = new sp_VendorCollection_Select(); Database.sp_VendorCollection_SelectTableAdapters.VendorCollection_SelectTableAdapter ta = new Database.sp_VendorCollection_SelectTableAdapters.VendorCollection_SelectTableAdapter(); ta.Fill(ds.VendorCollection_Select, strVendorCode); ddlVendorCollections.DataSource = ds.VendorCollection_Select; ddlVendorCollections.DataTextField = "CollectionName"; ddlVendorCollections.DataValueField = "CollectionKey"; ddlVendorCollections.DataBind(); } catch (Exception ex) { throw new System.Exception("There was an issue filling the Vendor Collection dropdown. Please contact support or try again. " + ex.ToString()); } } protected void fillHeadlineCombo() { try { Database.sp_Headline_Select ds = new sp_Headline_Select(); Database.sp_Headline_SelectTableAdapters.Headline_SelectTableAdapter ta = new Database.sp_Headline_SelectTableAdapters.Headline_SelectTableAdapter(); ta.Fill(ds.Headline_Select); ddlHeadline.DataSource =ds.Headline_Select; ddlHeadline.DataTextField = "Headline"; ddlHeadline.DataValueField = "HeadlineIdentifier"; ddlHeadline.DataBind(); } catch (Exception ex) { throw new System.Exception("There was an issue filling the Vendor Collection dropdown. Please contact support or try again. " + ex.ToString()); } } protected void fillVendorDropDown() { try { Database.sp_Vendor_Select ds = new sp_Vendor_Select(); Database.sp_Vendor_SelectTableAdapters.Vendor_SelectTableAdapter ta = new Database.sp_Vendor_SelectTableAdapters.Vendor_SelectTableAdapter(); ta.Fill(ds.Vendor_Select); ddlVendor.DataSource = ds.Vendor_Select; ddlVendor.DataTextField = "Name"; ddlVendor.DataValueField = "VendorCode"; ddlVendor.DataBind(); if (ds.Vendor_Select.Count > 0) { ddlVendor.SelectedIndex = ddlVendor.Items.IndexOf(ddlVendor.Items[0]); fillVendorCollectionDropDown(); } } catch (Exception ex) { throw new System.Exception("There was an issue filling the Vendor dropdown. Please contact support or try again. " + ex.ToString()); } } protected void btnSave_OnClick(object sender, EventArgs e) { try { string[] strItemCode = rcmbSKU.Text.Split(Convert.ToChar(",")); if (strItemCode.Length>0) { Database.sp_ItemAttributes_InsertTableAdapters.QueriesTableAdapter ta = new Database.sp_ItemAttributes_InsertTableAdapters.QueriesTableAdapter(); ta.ItemAttributes_Insert(strItemCode[0], txtPriceTagDescr.Text, Convert.ToInt32(ddlVendorCollections.SelectedValue), ddlHeadline.SelectedValue.ToString()); } else { throw new System.Exception("You must choose an item code. "); } this.parentMasterPage.showSuccess("Data was saved successfully. "); } catch (Exception ex) { this.parentMasterPage.showError("There was an issue saving the changes. " + ex.ToString()); } } protected void rgridSKU_OnSelectedIndexChanged(object sender, EventArgs e) { } protected void rgridPrintWithSKU_OnSelectedIndexChanged(object sender, EventArgs e) { } }}
I have a RadScheduler where I use the AdvancedInsertTemplate and AdvancedEditTemplate.
In the AdvancedForm user control I want to show different controls depending on the logged in user is Administrator or a normal user. So I've added a LoginView like this:
<asp:Panel runat="server" ID="AdvancedControlsPanel" CssClass="rsAdvMoreControls"> <asp:Panel runat="server"> <%-- RESOURCE CONTROLS --%> <ul class="rsResourceControls"> <li> <asp:LoginView ID="LoginView1" runat="server"> <RoleGroups> <asp:RoleGroup Roles="Administrator"> <ContentTemplate> <!-- Resource controls should follow the convention Res[Resource Name] for ID --> <scheduler:ResourceControl runat="server" ID="ResCustomer" Type="Customer" Label="Customer: "Skin='<%# Owner.Skin %>' /> <telerik:RadComboBox runat="server" ID="EmployeeComboBox" Label="Employee: " Visible="true"Skin="Outlook" Width="300px" CausesValidation="false" OnClientSelectedIndexChanged="OnClientSelectedIndexChanged"OnClientLoad="employeeClientLoad"> </telerik:RadComboBox> </ContentTemplate> </asp:RoleGroup> <asp:RoleGroup Roles="User"> <ContentTemplate> <asp:Label ID="LabelCustomer" runat="server" Text="CustomerName" /> </ContentTemplate> </asp:RoleGroup> </RoleGroups> </asp:LoginView> ...
When compiling I then get an error saying "ResCustomer does not exist in current context":
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)] public object Customer { get { return ResCustomer.Value; } set { ResCustomer.Value = value; } }
I then try to access the controls within the LoginView, but I can't find them:
LoginView lv = FindControl("LoginView1") as LoginView; RadComboBox employeeComboBox = lv.FindControl("EmployeeComboBox") as RadComboBox; Label customerLabel = lv.FindControl("LabelCustomer") as Label;
But now both the employeeComboBox and the customerLabel are null? The LoginView1 has been found, though.
And how do I find the ResCustomer?
On the page where the RadScheduler is I have a similar scenario, and there the controls within the LoginView are found without any problem.
What am I missing?
Regards, Jill-Connie Lorentsen
