Telerik Forums
UI for ASP.NET AJAX Forum
5 answers
183 views
Hi,

I am having a problem with the Radupload functionality in relation to the Clear button and custom fields; when I click on the clear button the control removes itself and creates a new version but it does not seem to remove the previous instance of the custom field resulting in two copies of the field after the clear is complete.  I used a Javascript example I found on this forum to add the custom field in the "OnClientAdded" event handler, but I guess the example is missing the cleanup logic.  I included placeholders for the OnClientClearing and OnClientDeleting event handlers ready for some logic :-)
Below is the code, can you help please?

Explanation:  the RadUpload control is being used within a grid that displays a list of document placeholders, when the document does not have an attached document, the RadUpload control is displayed, otherwise it is hidden and disabled.  Documents' Streams are being uploaded to a database using the dynamic property docid and docbarcode.  BTW, there is a save button above the grid (not displayed in code) that causes a full page postback.

Thank you
Ali M.

UploadDocuments.aspx
<telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowSelection="false" GridLines="None" 
    Width="100%" Height="500px" AllowSorting="true" EnableAjaxSkinRendering="true" 
    EnableViewState="true" AutoGenerateColumns="false"> 
    <MasterTableView AllowAutomaticUpdates="true" AutoGenerateColumns="false" AllowCustomSorting="true" 
        AllowNaturalSort="false" NoMasterRecordsText="This item has no documents"> 
            <Columns> 
                <telerik:GridBoundColumn UniqueName="DocumentID" DataField="DocumentID" HeaderText="ID" Display="false"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn UniqueName="Barcode" DataField="Barcode" HeaderText="Barcode" Display="true" ItemStyle-Width="110px"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn UniqueName="Type" DataField="Type" HeaderText="Document Type" Display="true" ItemStyle-Width="200px"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn UniqueName="FolderID" DataField="ID" HeaderText="FolderID" Display="false"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn UniqueName="ReceivedOn" DataField="Received On" HeaderText="Received On" Display="true" ItemStyle-Width="70px"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn UniqueName="LinkedOn" DataField="Linked On" HeaderText="Linked On" Display="true" ItemStyle-Width="70px"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn UniqueName="FileType" DataField="File Type" HeaderText="File Type" Display="true" ItemStyle-Width="130px"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn UniqueName="eDocSource" DataField="eDocSource" HeaderText="eDocSource" Display="false"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn UniqueName="Ref1" DataField="Ref1" HeaderText="Ref1" Display="false"></telerik:GridBoundColumn> 
                <telerik:GridCheckBoxColumn UniqueName="Linked" DataField="Linked" HeaderText="Linked" Display="false"></telerik:GridCheckBoxColumn> 
                <telerik:GridTemplateColumn UniqueName="doclink" ItemStyle-Width="300px"> 
                    <ItemTemplate> 
                        <telerik:RadUpload ID="RadUpload1" runat="server" MaxFileInputsCount="1" RegisterWithScriptManager="true" 
                                TargetFolder="" OnValidatingFile="RadUpload1_ValidatingFile" EnableFileInputSkinning="true" 
                                ControlObjectsVisibility="RemoveButtons" Visible='<%# IIf(DataBinder.Eval(Container.DataItem, "Linked"), false, true) %>' 
                                Enabled='<%# IIf(DataBinder.Eval(Container.DataItem, "Linked"), false, true) %>' 
                                docid='<%# DataBinder.Eval(Container.DataItem, "DocumentID") %>' InputSize="25" 
                                docbarcode='<%# DataBinder.Eval(Container.DataItem, "Barcode") %>' 
                                OnClientAdded="OnClientAddedHandler" OnClientDeleting="OnClientDeleting" OnClientClearing="uploadFileClearing" 
                                OnClientFileSelected="uploadFileSelected"> 
                        </telerik:RadUpload> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
            </Columns> 
    </MasterTableView> 
    <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="false"> 
            <Scrolling AllowScroll="true" /> 
            <Selecting AllowRowSelect="true" /> 
            <ClientEvents OnRowCreating="radDummy" OnRowCreated="radDummy" /> 
    </ClientSettings> 
</telerik:RadGrid> 


UploadDocuments.aspx.vb
'*** some validation here - removed from example 
Try 
    _sDocid = TryCast(sender, Telerik.Web.UI.RadUpload).Attributes.Item("docid") 
Catch ex1 As Exception 
    _isValid = False 
End Try 
If Not _isValid Then 
    '** deal with invalid upload 
    Return 
End If 
Try 
    _barcode = TryCast(sender, Telerik.Web.UI.RadUpload).Attributes.Item("docbarcode") 
Catch ex1 As Exception 
    _isValid = False 
End Try 
If Not _isValid Then 
    '** deal with invalid upload 
    Return 
End If 
 
Try 
    _docName = e.UploadedFile.GetFieldValue("Name") 
    _docName = _docName.Trim() 
Catch ex1 As Exception 
    _docName = "" 
End Try 
 
If _docName.Length = 0 Then 
    _docName = String.Format("Document [{0}]", _barcode) 
End If 
 
'** process the upload 
'** -- code removed from example 


uploaddocuments.js
var numberOfCustomFields = 0; 
function OnClientAddedHandler(sender, eventArgs) { 
  var inputRow = eventArgs.get_row(); 
  var uList = inputRow.parentNode; 
  var count = 0; 
 
  // add a new row for a Title field 
  newRow = document.createElement("li"); 
  count++; 
  uList.insertBefore(newRow, inputRow); 
  var label = document.createElement("span"); 
  label.innerHTML = "Name : "; 
  label.style.width = "150px"; 
  label.style.fontSize = "10pt"; 
  label.style.fontWeight = "bold"; 
  input = document.createElement("input"); 
  input.type = "text"; 
  input.style.width = "200px"; 
  input.id = input.name = sender.getID("Name"); 
  newRow.appendChild(label); 
  newRow.appendChild(input); 
 
  //add a File label in front of the file input 
  var fileInputSpan = inputRow.getElementsByTagName("span")[0]; 
  label = document.createElement("span"); 
  label.innerHTML = "File :&nbsp;&nbsp;&nbsp;&nbsp;"; 
  label.style.width = "150px"; 
  label.style.fontSize = "10pt"; 
  label.style.fontWeight = "bold"; 
  label.style.verticalAlign = "middle"; 
  label.style.paddingTop = "5px"; 
  inputRow.insertBefore(label, fileInputSpan); 
  numberOfCustomFields = count; 
}; 
 
function uploadFileClearing(sender, eventArgs) { 
}; 
 
function OnClientDeleting(sender, eventArgs) { 
}; 







Genady Sergeev
Telerik team
 answered on 31 Mar 2010
2 answers
167 views
Hi,

 We are facing an weird problem. We have a RadCaptcha inside an asp:login template and have one RadPanel where this asp:login is inside.
 When the Captcha Generate New Machine is asked for, them an AJAX request is started but the interesting is the return: no image at all, captcha is there but the div's responsible for the images are not.
 Sample code:

    <form id="frmLogin" runat="server">  
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"   
            HttpHandlerUrl="~/SBP.UI.WebResource.axd">  
    </telerik:RadScriptManager> 
    <div id="login" align="center">  
<div style="position:absolute; left:0; right:0; top:0; height:35px; background-color:#d9d9d9; text-align:center">  
    <img src="/App_Themes/login/logo_sbp.png" width="93" height="35" /> 
 
</div> 
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Black">  
        </telerik:RadAjaxLoadingPanel> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"   
            DefaultLoadingPanelID="RadAjaxLoadingPanel1">  
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="LogOnSBP">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="LogOnSBP"   
                            LoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelRenderMode="Inline" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
        <telerik:RadAjaxPanel ID="rpLogin" runat="server">  
            <asp:Login ID="LogOnSBP" runat="server"   
                FailureText="Acesso negado" FailureTextStyle-CssClass="falhaAcesso" Orientation="Horizontal" 
                LoginButtonText="Entrar"   
                OnAuthenticate="LogOn1_Authenticate" PasswordLabelText="Senha:" 
                PasswordRequiredErrorMessage="Pass required"   
                TitleText="" UserNameLabelText="Login:"   
                UserNameRequiredErrorMessage="User required"   
                VisibleWhenLoggedIn="False" DestinationPageUrl="~/Default.aspx"   
                DisplayRememberMe="False" > 
                <CheckBoxStyle HorizontalAlign="Left" /> 
                <LoginButtonStyle CssClass="btLogin" /> 
                <LayoutTemplate> 
                    <table border="0" cellpadding="1" cellspacing="0"   
                        style="border-collapse:collapse;">  
                        <tr> 
                            <td> 
                                <table border="0" cellpadding="0">  
                                    <tr> 
                                        <td align="left">  
                                            <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName"><asp:RequiredFieldValidator CssClass="erroFail" ID="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="User required" ToolTip="Usuário necessário" ValidationGroup="LogOnSBP">*</asp:RequiredFieldValidator> Login:</asp:Label>   
                                            <asp:TextBox CssClass="tiLogin" ID="UserName" runat="server"></asp:TextBox> 
                                        </td> 
                                        <td align="left" style=" padding-left:10px;">  
                                            <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password"><asp:RequiredFieldValidator CssClass="erroFail" ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Pass required" ToolTip="Senha necessária" ValidationGroup="LogOnSBP">*</asp:RequiredFieldValidator> Senha:</asp:Label> 
                                            <asp:TextBox CssClass="tiSenha" ID="Password" runat="server" TextMode="Password"></asp:TextBox> 
                                              
                                        </td> 
                                    </tr> 
                                    <tr> 
                                        <td style="width:180px; position:relative; height:80px;">  
                                            <telerik:RadCaptcha ID="rcBotProtection" runat="server"   
                                                ProtectionMode="InvisibleTextBox">  
                                            </telerik:RadCaptcha> 
                                              
                                            <telerik:RadCaptcha ID="rcCaptcha"  runat="server"  CaptchaLinkButtonText=""   
                                                ValidatedTextBoxID="txtCaptcha"  ValidationGroup="LogOnSBP"   
                                                CaptchaTextBoxLabel=""  CssClass="rcAreaCaptcha" EnableRefreshImage="true"   
                                                HttpHandlerUrl="~/SBP.UI.WebResource.axd" Height="24px" Width="128px"   
                                                ImageStorageLocation="Cache" IgnoreCase="False">  
                                               <CaptchaImage ImageCssClass="rcCaptchaImage" TextLength="5" LineNoise="High" BackgroundNoise="High" RenderImageOnly="true"/>  
                                            </telerik:RadCaptcha> 
                                        </td> 
                                        <td style="width:180px; padding-left:10px; text-align:left">  
                                        <div style="float:right"><asp:Label ID="Label1" runat="server"  CssClass="lblCaptcha" AssociatedControlID="rcCaptcha">Digite os caracteres:</asp:Label><asp:TextBox CssClass="tiCaptcha" ID="txtCaptcha" runat="server"></asp:TextBox><asp:RequiredFieldValidator CssClass="erroFail" ID="CaptchaRequired" runat="server" ControlToValidate="txtCaptcha" ErrorMessage="Pass required" ToolTip="Captcha necessário" ValidationGroup="LogOnSBP">*</asp:RequiredFieldValidator></div>  
                                        </td> 
                                    </tr> 
                                  <tr> 
                                        <td colspan="2" style="text-align:center">  
                                            <asp:Button ID="Login" runat="server" CommandName="Login" CssClass="btLogin" Text="Entrar" ValidationGroup="LogOnSBP" /> 
                                            <span style="display:block; color:#D00"><asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal></span>  
                                        </td> 
                                    </tr> 
                                </table> 
                            </td> 
                        </tr> 
                    </table> 
                </LayoutTemplate> 
                <InstructionTextStyle Font-Italic="True" ForeColor="Black" /> 
                <LabelStyle HorizontalAlign="Left" /> 
 
                <FailureTextStyle CssClass="falhaAcesso"></FailureTextStyle> 
            </asp:Login> 
        </telerik:RadAjaxPanel> 
    </div> 
    </form> 

Does anyone imagine what is going on ? Tought about something related to Javascript...


Best regards,

Daniel Bichuete

Pero
Telerik team
 answered on 31 Mar 2010
2 answers
671 views
Hello,

I need to use a for loop instead of a foreach loop to update all the TextBox values(txtQuantity), but I don't know how to reference/cast the GridDataItem to the RadGrid while not being inside of a RadGrid event.
This OnClick works on the most part.  But if evaluates to false it just continues.  I need it to stop.

      protected void btnUpdateCart_Click(object sender, EventArgs e) 
      { 
         // TODO: Use for loop to stop when an expression evaluates to false. 
         //for (int i = 0; i < grdCart.Items.Count; i++) 
         foreach (GridDataItem dataItem in grdCart.MasterTableView.Items) 
         { 
            // TODO: Cast (GridDataItem)dataItem here and remove foreach 
            string strItemId = dataItem.GetDataKeyValue("ID").ToString(); 
            RadTextBox txtQuantity = (RadTextBox)dataItem.FindControl("txtQuantity"); 
            int itemId, quantity; 
            bool success = false; 
 
            if (Int32.TryParse(strItemId, out itemId) && Int32.TryParse(txtQuantity.Text, out quantity)) 
            { 
               success = _cartItem.Update(itemId, quantity); 
            } 
 
            lblFeedback.Text = success ? "Your cart has been successfully updated!" : "There was an error updating your cart.<br />Please verify that the quantity value is a number and try again."; 
         } 
 
         grdCart.Rebind(); 
      } 

Thank you in advance,
Ronnie
Ronnie
Top achievements
Rank 1
 answered on 31 Mar 2010
1 answer
89 views
Hello,

Is it possible to have a confirmation message when copy/paste in a MOSS RadEditor?
In the ToolsFile.xml file I added:
...  
    <tool name="FormatStripper">  
      <tool name="StripCss" /> 
      <tool name="StripFont" /> 
      <tool name="StripWord" /> 
    </tool> 
...  
 

In the ConfigFile.xml file I added:
...  
<property name="StripFormattingOptions">MSWord, Css, Font</property> 
.... 

But unfortunatly no message appeared on copy/paste, only security popups appeared (with IE8).

Thanks by advance.

Regards.
Didier.

Rumen
Telerik team
 answered on 31 Mar 2010
9 answers
240 views
Hello,

I am developing an ASP.Net solution that combines RadAjaxManger, RadLayout/Zone/Dock, and RadChart controls.  This question is about using the first two (Ajax and Docks) together.  Here is the setup:

- There is a static RadDockLayout, and three static RadDockZones. 
- Users click and drag from a RadTreeView to add content to the layout.  The drop action causes a RadDock to be added to the targeted RadDockZone.  A WebUserControl is added to the ContentContainer of the RadDock.

This works fine, and user modifications to the layout are persisted to a database.  I am now Ajaxifying the layout, and am having problems.  I'm using a RadAjaxManager.  Since the docks are added dynamically, I'm using the:

            RadAjaxManager1.AjaxSettings.AddAjaxSetting(dock, dock)

command to Ajaxify the docks as they are added to the page, and indicate that they should only update themselves.  Regardless of the AjaxManager settings, however, the docks will almost always update all other docks in the layout.  The exception to this is if I add an AjaxManager dependency to each RadDockZone, indicating that each should only update itself.  In this case, the docks only update the docks in the same zone.  I have also tried adding an ASP:Label control to the page and indicating that the docks should only update that label; this results in the label being updated, along with all the other docks in the layout.

Question: can this be done?  Can I have dynamically-added docks that only update themselves on a Postback?  My plan is to have several reports on the page, and I can't afford to have a dozen reports updating every time a change is made to a single dock. 

Thank you!
Pero
Telerik team
 answered on 31 Mar 2010
2 answers
223 views
Hi,
 I am unable to run the live demos it shows the error on
   <add assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
plus there is a tag not defined error on
 <qsf:ConfiguratorPanel ID="ConfiguratorPanel1" runat="server" Expanded="true" Orientation="Vertical">
I added
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
 but still there is error on " ConfiguratorPanel"
Apart from these errors,can you please tell me if its possible to have more than one column in RadListBox ?
Please assist me ASP
Thanks
Regards
Faf


farheena JAwed
Top achievements
Rank 1
 answered on 31 Mar 2010
0 answers
62 views
can  we sub divide our time Time slot Region into more parts
eg:
suppose we have 10 hour time slot and that have 10 regions of duration of 1 hour, so i want to sub divide this 1hour Time region into 6 parts of each 10 min, so that on Stretching of any appointment its duration will allow me to Stretch 10 min duration to Stretching not for 1 hour Stretching duration that is the default behaviour of Scheduler if i set 1 hour region.
so i just want to divide region into sub region so that Stretching is done on sub regions


Thanks
Regraded As:
Muhammad Ali
Web Developer
Softech World Wide LLC.
Muhammad ali
Top achievements
Rank 1
 asked on 31 Mar 2010
4 answers
111 views
Hello,

I have created a SharePoint webpart with some Telerik controls in, mainly TabStrip and MultiPage. Since SharePoint destroyes its pages on every postback, I wanted zo Ajaxify my controls.
Everything seems to work fine, but when I update my tabstrip and underlying multipageview, data is loaded in my controls, but I can't navigate on my tabs anymore (before the update, and the data is loaded I can click them).
I assume there must be something I have forgotten, but I just can't find it.

Here is my (simplified) code
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> 
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="btnSearch"> 
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadTabStripResults" /> 
                <telerik:AjaxUpdatedControl ControlID="RadMultiPageresults" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="listAttests"> 
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadTabStripDetails" /> 
                <telerik:AjaxUpdatedControl ControlID="RadMultiPageDetails" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManager> 
... 
    <telerik:RadTabStrip ID="RadTabStripSearch" runat="server" Skin="Outlook" MultiPageID="RadMultiPageSearch" SelectedIndex="0"> 
        <Tabs> 
            <telerik:RadTab Text="Zoeken"> 
            </telerik:RadTab> 
        </Tabs> 
    </telerik:RadTabStrip> 
    <telerik:RadMultiPage ID="RadMultiPageSearch" runat="server" SelectedIndex="0" CssClass="pageView"> 
        <telerik:RadPageView ID="RadPageViewSearch" runat="server"> 
... 
            <asp:Button ID="btnSearch" runat="server" Text="Zoeken" /> 
...                                 
        </telerik:RadPageView> 
    </telerik:RadMultiPage> 
     <telerik:RadTabStrip ID="RadTabStripResults" runat="server" Skin="Outlook" MultiPageID="RadMultiPageResults" SelectedIndex="0"> 
            <Tabs> 
                <telerik:RadTab Text="Resultaten"> 
                </telerik:RadTab> 
            </Tabs> 
        </telerik:RadTabStrip> 
        <telerik:RadMultiPage ID="RadMultiPageresults" runat="server" SelectedIndex="0" CssClass="pageView"> 
            <telerik:RadPageView ID="RadPageViewResults" runat="server"> 
...                 
                <asp:ListBox ID="listAttests" runat="server" Width="300px" AutoPostBack="true"></asp:ListBox> 
...    
            </telerik:RadPageView> 
        </telerik:RadMultiPage> 
 
    <telerik:RadTabStrip ID="RadTabStripDetails" runat="server" Skin="Outlook" MultiPageID="RadMultiPageDetails" SelectedIndex="0"> 
        <Tabs> 
            <telerik:RadTab Text="Attest" PageViewID="RadPageViewAttestDetails"> 
            </telerik:RadTab> 
            <telerik:RadTab Text="Redenen" PageViewID="RadPageViewReasonDetails"> 
            </telerik:RadTab> 
            <telerik:RadTab Text="Artikels" PageViewID="RadPageViewArticles"> 
            </telerik:RadTab> 
        </Tabs> 
    </telerik:RadTabStrip> 
    <telerik:RadMultiPage ID="RadMultiPageDetails" runat="server" SelectedIndex="0" CssClass="pageView"> 
        <telerik:RadPageView ID="RadPageViewAttestDetails" runat="server"> 
... 
        </telerik:RadPageView> 
        <telerik:RadPageView ID="RadPageViewReasonDetails" runat="server" CssClass="pageView"> 
... 
        </telerik:RadPageView> 
        <telerik:RadPageView ID="RadPageViewArticles" runat="server" CssClass="pageView"> 
... 
        </telerik:RadPageView> 
    </telerik:RadMultiPage> 

The first and second tabstrips might have the same problem, but as there is only one tab (I use them to obtain the same styling on the 3 blocks) I don't notice a problem there. On the 3rd block however I have 3 tabs, so it would be nice if I could change panels there.

Just to give you an Idea of what this thing is supposed to do:
  • in the Search section, I can enter a searchstring and click the search button
  • in the Results section my search results are shown in a listbox
  • when I select a result in the listbox, the details of this result are shown in the Details section

I hope someone comes up with an idea.
Hans Santens
Top achievements
Rank 1
 answered on 31 Mar 2010
2 answers
125 views
Hi All,

This is my first time using Telerik in ASP.Net project.
In my project, I have used TelerikGrid for displaying and editing data. Please refer to code below:

<telerik:RadGrid ID="rgAddData" GridLines="None" runat="server" AllowAutomaticDeletes="True"
     AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True" PageSize="10" EnableLinqExpressions="false"
     AutoGenerateColumns="False" OnItemUpdated="rgAddData_ItemUpdated" OnItemDeleted="rgAddData_ItemDeleted"
     OnItemInserted="rgAddData_ItemInserted" OnItemCommand="rgAddData_ItemCommand">
     <PagerStyle Mode="NextPrevAndNumeric" />
             <MasterTableView Width="100%" EditMode="InPlace"
                                CommandItemSettings-AddNewRecordImageUrl="../images/img_Add.png"
                                CommandItemSettings-AddNewRecordText = "Add Data"                       
                                CommandItemSettings-RefreshText = ""
                                CommandItemSettings-RefreshImageUrl="../images/img_Blank.png"
                                ShowHeadersWhenNoRecords="true" ShowHeader="true"
                                CommandItemDisplay="Top" DataKeyNames="DataID"
                                AutoGenerateColumns="False"
                                HeaderStyle-Font-Bold="true">
                                <Columns>                                                             
                                    <telerik:GridDropDownColumn HeaderText="Client" UniqueName="Client" ColumnEditorID="DropDownStyle">
                                    </telerik:GridDropDownColumn>                                                            
                                    
                                    <telerik:GridTemplateColumn HeaderText="Age" UniqueName="Age">
                                        <ItemTemplate>
                                            <asp:DropDownList ID="ddlAge" runat="server" Style="width:110px;"></asp:DropDownList>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>                    
                            
                                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                                    </telerik:GridEditCommandColumn>
                                    
    
                                    <telerik:GridButtonColumn ConfirmText="Delete this data?" ConfirmDialogType="RadWindow"
                                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                                        UniqueName="DeleteColumn">
                                        <ItemStyle HorizontalAlign="Center" CssClass="addCassetteImageButton" />
                                    </telerik:GridButtonColumn>
                                </Columns>
                
                                <EditFormSettings ColumnNumber="2" CaptionDataField="DataID" CaptionFormatString="Edit cassette {0}"> </EditFormSettings>
                            </MasterTableView>          
                        </telerik:RadGrid>
                                                
                        <telerik:GridDropDownListColumnEditor ID="DropDownStyle" runat="server" DropDownStyle-Width="110px" />
                        
                        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager> 
---------------------------------------------------------------------------------------------------------------
I have an asp:dropdownlist control declared under the ItemTemplate. This drop down list will then bind with the data return from the file from another c# project. Below is the code:

 public static List<KeyValuePair<int, string>> GetAgeList()
        {
            List<KeyValuePair<int, string>> ageList = new List<KeyValuePair<int, string>>();
            for (int i = 0; i < 10; i++)
            {
                ageList.Add(new KeyValuePair<int, string>(i, i + " yrs"));
            }
            return ageList;
        }

--------------------------------------------------------------------------

Then in my C# code, I want to use findControl to get the "ddlAge" in order to bind with the return values from the above codes.
Below is my code:

protected void rgAddCassette_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {             
        ((DropDownList)e.Item.FindControl("ddlAge")).DataSource = Services.ListOfValues.GetAgeList();
        ((DropDownList)e.Item.FindControl("ddlAge")).DataBind();
    }

---------------------------------------------
However, I got this error cannot find the control.
Could anyone please do help me on how should I use the FindControl to get the asp dropdownlist control that I declared under ItemTemplate?
In my project, there are 3 RadGrid with similar settings, where I've added the asp drop down list under itemtemplate and bind with the value list return from other project.

Thanks for the help!




Alice Leong
Top achievements
Rank 1
 answered on 31 Mar 2010
1 answer
115 views
I have the following RadDock on the my page and noticed that when I reorder docs the first time this new order isnt saved.  But second time thru if i preform a reorder everything sticks like its supposed to.

ASCX code:
<telerik:RadDockLayout runat="server" ID="RadDockLayout1"    
    OnLoadDockLayout="RadDockLayout1_LoadDockLayout"   
    OnSaveDockLayout="RadDockLayout1_SaveDockLayout"    
    StoreLayoutInViewState=true 
    > 
    <div id="div_rdZoneCurrentCycle">  
    <telerik:RadDockZone runat="server" ID="RadDockZone_ExistingPriorities"   
        BorderStyle="None"   
        MinHeight="30px" width="100%"   
        > 
    </telerik:RadDockZone> 
    </div> 
</telerik:RadDockLayout> 

Class code:
   public partial class SSPPrioritizePriorities : System.Web.UI.UserControl  
   {  
       private List<DockState> CurrentDockStates  
       {  
           get 
           {  
               // Store the info about the added docks in the session.  
 
               List<DockState> _currentDockStates = (List<DockState>)Session["CurrentDockStatesDynamicDocks"];  
               if (Object.Equals(_currentDockStates, null))  
               {  
                   _currentDockStates = new List<DockState>();  
                   Session["CurrentDockStatesDynamicDocks"] = _currentDockStates;  
               }  
               return _currentDockStates;  
           }  
           set 
           {  
               Session["CurrentDockStatesDynamicDocks"] = value;  
           }  
       }
       #endregion  
 
       const string TitleBarText = "TitleText";  
       const string CurrentRank = "CurRankText";  
       const string PreviousRank = "PreRankText";
       #endregion  
 
       #region " Page Load Events " 
 
       protected void Page_Load(object sender,EventArgs e)  
       {  
       }  
 
       protected override void OnInit(EventArgs e)  
       {  
           base.OnInit(e);  
 
           if (!Page.IsPostBack)  
           {  
               using (ObjectsContext context = new ObjectsContext())  
               {  
                   MyManager manager = new MyManager(context);  
 
                   CurrentCyclePriorities = manager.something.Cycle();  
                   CurrentCycleSSP = manager.somehingelse.GetCurrent(this._SSPK);  
                   PreviousCycleSSP = manager.somehingelse.GetPrevious(this._SSPK);  
                   LoadPriorities();  
                    
               }  
 
           }  
           else 
           {  
               for (int i = 0; i < CurrentDockStates.Count; i++)  
               {  
                   RadDock dock = CreateRadDockFromState(CurrentDockStates[i]);  
                   RadDockLayout1.Controls.Add(dock);  
                   CreateSaveStateTrigger(dock);  
               }  
           }  
 
           SetRadDockOrder();  
       }
       #endregion  
 
       #region " Priorities Load Events " 
 
       protected void LoadPriorities()  
       {  
           CreateRadDock(sspPrevious.Priority, true, true, false,   
       }
       #endregion  
 
       #region " Dock Events "
       #region " Create "  
 
       private void CreateRadDock(BusinessObjects.Priority apriority, Boolean BottomDock, Boolean Closed, Boolean New, int previousRanking, int? CurrentRanking)  
       {  
            try 
            {  
                // Create the Rad Dock and set properties  
 
                RadDock dock = new RadDock();  
                dock.DockMode = DockMode.Docked;  
                dock.DockHandle = DockHandle.TitleBar;  
                dock.Collapsed = true;  
                dock.Width = Unit.Percentage(96);  
                dock.Skin = "MySkin";  
                dock.EnableEmbeddedSkins = false;  
                dock.EnableRoundedCorners = true;  
                dock.EnableAnimation = true;  
                dock.Font.Name = "Arial";  
                int intIndex = dock.Index;  
 
                dock.AutoPostBack = true;  
                dock.CommandsAutoPostBack = true;  
 
                // Create the TitleBar and add to Rad Dock  
 
                TitleBarTemplate2 tbt = new TitleBarTemplate2();  
                tbt.GenerateTitleBar(dock.TitlebarContainer, 5);  
                dock.TitlebarTemplate = tbt;  
 
                // Add Rad Dock Title information  
 
                dock.UniqueName = apriority.PK.ToString();  
                dock.ID = string.Format("rd{0}", dock.UniqueName);  
                dock.Title = "<span style=\"font-size:14px;\"><b>" + apriority.PK.ToString() + "</b></span> ";  
                ((Label)dock.TitlebarContainer.Controls[0].FindControl(TitleBarText)).Text = dock.Title;  
 
                // Add Rad Dock Previous Rank information  
 
                if (!New)  
                {  
                    String preRanking = "<span style=\"font-size:14px;\"><b>(" + previousRanking.ToString() + ")</b></span>";  
                    ((Label)dock.TitlebarContainer.Controls[0].FindControl(PreviousRank)).Text = preRanking;  
                }  
 
                // Set Rad Dock Events and Triggers  
 
                if (BottomDock)  
                    dock.OnClientDragStart = "OnClientDragStart";  
                CreateSaveStateTrigger(dock);  
 
 
                    RadDockZone_ExistingPriorities.Controls.Add(dock);  
 
            }  
 
            catch (Exception ex)  
            {  
                string s = ex.StackTrace;  
            }  
       }
       #endregion  
 
       #region " Order " 
 
       private void SetRadDockOrder()  
       {  
           foreach (RadDock dock in RadDockZone_ExistingPriorities.Docks)  
           {  
               ((Label)dock.TitlebarContainer.Controls[0].FindControl(CurrentRank)).Text = "";  
               int newRank = dock.Index + 1;  
               String newRanking = "<span style=\"font-size:14px;\"><b>" + newRank.ToString() + ".</b></span>";  
               ((Label)dock.TitlebarContainer.Controls[0].FindControl(CurrentRank)).Text = newRanking;  
           }  
       }
       #endregion  
 
       #region " States " 
 
       private RadDock CreateRadDockFromState(DockState state)  
       {  
 
           RadDock dock = new RadDock();  
 
           //// Create the TitleBar and add to Rad Dock  
 
           TitleBarTemplate2 tbt = new TitleBarTemplate2();  
           tbt.GenerateTitleBar(dock.TitlebarContainer, 5);  
           dock.TitlebarTemplate = tbt;  
 
           //// Add Rad Dock Title information  
 
           dock.UniqueName = state.UniqueName;  
           //dock.Index = state.Index;  
           dock.Title = "<span style=\"font-size:14px;\"><b>" + dock.UniqueName + "</b></span> ";  
           ((Label)dock.TitlebarContainer.Controls[0].FindControl(TitleBarText)).Text = state.Title;  
 
           return dock;  
       }  
 
       private void CreateSaveStateTrigger(RadDock dock)  
       {  
           // Ensure that the RadDock control will initiate postback when its position changes on the client or any of the commands is clicked.  
           // Using the trigger we will "ajaxify" that postback.  
 
           dock.AutoPostBack = true;  
           dock.CommandsAutoPostBack = true;  
       }  
 
       protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)  
       {  
           foreach (DockState state in CurrentDockStates)  
           {  
               e.Positions[state.UniqueName] = state.DockZoneID;  
               e.Indices[state.UniqueName] = state.Index;  
           }  
       }  
 
       protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)  
       {  
           CurrentDockStates = new List<DockState>();  
           foreach (DockState ds in RadDockLayout1.GetRegisteredDocksState())  
           {  
               CurrentDockStates.Add(ds);  
           }  
       }
       #endregion  
 
       #endregion  
 
   } 

Again, the problem is that initially the page loads the dynamically created RadDocs in thier correct order.  I move the bottom most doc to the be the top most doc and the page posts back.  Ok so while the page posts back, the order doenst change and mr bottom doc remains on the bottom.  BUT!!! if i reorder AFTER the first post back, the docs retain thier placement.

J
Pero
Telerik team
 answered on 31 Mar 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?