Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
273 views
Hi,

I have a treelist control with load on demand enabled. I need to expand items to first level for which i used " ExpandToLevel(1) " . Things were fine when i was having the older version of telerik. I recently upgraded it to the latest version and found this issue. On initial load things are fine. When i try to expand any item all the expanded levels and the buttons for expanding are lost and only the first level items are seen. For more information reg the problem pls check the sample code below.
protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                RadTreeList1.ExpandToLevel(1);               
            }           
        }
 
        protected void RadTreeList1_NeedDataSource(object sender, TreeListNeedDataSourceEventArgs e)
        {
            RadTreeList1.DataSource = GetDataTable("SELECT * FROM TestItems WHERE ParentID IS NULL", null);
        }
 
        protected void RadTreeList1_ChildItemsDataBind(object sender, TreeListChildItemsDataBindEventArgs e)
        {
            int id = Convert.ToInt32(e.ParentDataKeyValues["ID"].ToString());
            SqlParameter param = new SqlParameter();
            param.ParameterName = "@ID";
            param.Value = id;
            e.ChildItemsDataSource = GetDataTable("SELECT * FROM TestItems WHERE ParentID = @ID", param);
        }
 
        private DataTable GetDataTable(string query, SqlParameter param)
        {
            SqlConnection conn = new SqlConnection(ConnString);
            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand command = new SqlCommand(query, conn);
 
            if (param != null)
            {
                command.Parameters.Add(param);
            }
            adapter.SelectCommand = command;
            DataTable myDataTable = new DataTable();
 
            conn.Open();
            try
            {
                adapter.Fill(myDataTable);
            }
            finally
            {
                conn.Close();
            }
 
            return myDataTable;
        }
 
        private void ConvertEmptyValuesToDBNull(Hashtable values)
        {
            List<object> keysToDbNull = new List<object>();
 
            foreach (DictionaryEntry entry in values)
            {
                if (entry.Value == null || (entry.Value is String && String.IsNullOrEmpty((String)entry.Value)))
                {
                    keysToDbNull.Add(entry.Key);
                }
            }
 
            foreach (object key in keysToDbNull)
            {
                values[key] = DBNull.Value;
            }
        }
 
        private void ExecuteNonQuery(string commandText, Hashtable parameters)
        {
            SqlConnection conn = new SqlConnection(ConnString);
            SqlCommand command = new SqlCommand(commandText, conn);
 
            foreach (DictionaryEntry entry in parameters)
            {
                command.Parameters.AddWithValue(entry.Key.ToString(), entry.Value);
            }
 
            conn.Open();
            try
            {
                command.ExecuteNonQuery();
            }
            finally
            {
                conn.Close();
            }
        }

Thanks,
Karthik
Pavlina
Telerik team
 answered on 06 Aug 2013
7 answers
331 views

In my aspx page, when user click a "Preview" button in radtoolbar it will redirect to another page with querystring. but i get the following error

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

I had already tried to use both scriptblock and codeblock, but it doen't work

<%@ Page Title="" Language="VB" MasterPageFile="~/LRDB.master" AutoEventWireup="false" CodeFile="SIMPER_details.aspx.vb" Inherits="TrainingAdmin_SIMPER_details" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
       .table_photo
        {
            width: 100px;
            height: auto;
        }
 
      .table_content
      {
          width: 400px;
          }
             
            .table_header
            {
                width: 282px;
                height: 15px;
                background-color: #E7EEF6;
            }
             
       .style6
    {
        width: 392px;
        height: 15px;
        background-color: #E7EEF6;
        font-weight: 700;
    }
             
       </style>
</asp:Content>
 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
       <script type="text/javascript">
           //        var lastClickedItem = null;
           //        var clickCalledAfterRadprompt = false;
           //        var clickCalledAfterRadconfirm = false;
           //        function onClientButtonClicking(sender, args) {
           //            if (args.get_item().get_text() == "Create SIMPER") {
           //                if (!clickCalledAfterRadconfirm) {
           //                    args.set_cancel(true);
           //                    lastClickedItem = args.get_item();
           //                    radconfirm("Are you sure you want to create?", confirmCallbackFunction);
           //                }
           //            }
           //            else if (args.get_item().get_text() == "Delete") {
           //                if (!clickCalledAfterRadconfirm) {
           //                    args.set_cancel(true);
           //                    lastClickedItem = args.get_item();
           //                    radconfirm("Are you sure you want to delete?", confirmCallbackFunction);
           //                }
           //            }
 
           //        }
 
           //        function confirmCallbackFunction(args) {
           //            if (args) {
           //                clickCalledAfterRadconfirm = true;
           //                lastClickedItem.click();
           //            }
           //            else
           //                clickCalledAfterRadconfirm = false;
           //            lastClickedItem = null;
           //        }
 
           //        OnClientButtonClicking = "onClientButtonClicking"
 
           function ShowSIMPER(id) {
               var wnd = window.radopen("SIMPER_view.aspx?SIMPER_ID=" + id + "&UserID=0", "SIMPER_PDF");
               wnd.SetSize("700", "700");
               wnd.moveTo("250", "140");
               //return false;
           }
        </script>
    </telerik:RadScriptBlock>
 
 
 
    <telerik:RadWindowManager runat="server" ID="rwm1">
    </telerik:RadWindowManager>
     
 
 
    <%--<telerik:RadToolBar ID="RadToolBar1" runat="server" Width="100%" Skin="Windows7" OnClientButtonClicking="onClientButtonClicking" >--%>
 
    <telerik:RadToolBar ID="rtbMenu" runat="server" Width="100%" Skin="Windows7">
        <Items>
            <telerik:RadToolBarButton Value="Preview" Text="Preview SIMPER" Width="150px" Enabled="false"  />
            <telerik:RadToolBarButton IsSeparator="true" />
            <telerik:RadToolBarButton Value="Refresh" Text="Refresh" Width="80px"  CausesValidation="false" />
            <telerik:RadToolBarButton IsSeparator="true" />
            <telerik:RadToolBarButton Value="Back" Text="Back" Width="80px"  CausesValidation="false"/>
            <telerik:RadToolBarButton Value="BackSeparator" IsSeparator="true" />
        </Items>
    </telerik:RadToolBar>
    <telerik:RadFormDecorator ID="RpFormDecorator" runat="server" Skin="Windows7" DecoratedControls="All" EnableRoundedCorners="true" /> 
 
   
 
 
           <div id="content_function" class="content_function" >
 
 
   
 
 
                              <div style="margin-left:5px;">
                              <table cellpadding="1" width="1000" style="vertical-align:top">
                              <tr>
                              <td align="left" valign="top" class="style6">Name
                              </td>
                              <td align="left" valign="top" class="table_content">
                              <asp:Label ID="lb_name" runat="server"></asp:Label>
                              </td>
                              <td align="left" valign="top" class="table_content" rowspan="8">
                                <telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" ImageUrl="../images/blank_photo.jpg"
                                               Width="100px" ResizeMode="Fit" AlternateText="No picture available" style="border-style:dotted;"
                                               CssClass="preview" AutoAdjustImageControlSize="false"></telerik:RadBinaryImage>
                                                     </td>
                              </tr>
                              <tr>
                              <td align="left" valign="top" class="style6">Gender
                              </td>
                              <td align="left" valign="top" class="table_content">
                              <asp:Label ID="lb_gender" runat="server"></asp:Label>
                              </td>
                              </tr>                             
                              <tr>
                              <td align="left" valign="top" class="style6">Department
                              </td>
                              <td align="left" valign="top" class="table_content">
                              <asp:Label ID="lb_dept" runat="server"></asp:Label>
                              </td>
                              </tr>
                               
                              <tr>
                              <td align="left" valign="top" class="style6"> </td>
                              <td align="left" valign="top" class="table_content">
                                   </td>
                              </tr>
                               
                              <tr>
                              <td align="left" valign="top" class="style6"><span class="style4">Required
                                  information if create SIMPER:</span> </td>
                              <td align="left" valign="top" class="table_content">
                                   </td>
                              </tr>
                               
                              <tr>
                              <td align="left" valign="top" class="style6">Valid From<br />
                                  </td>
                              <td align="left" valign="top" class="table_content">
                                  <telerik:RadDatePicker ID="RadDatePicker_ValidFrom" Runat="server"
                                      Culture="en-US" MinDate="1/1/1900">
                                  </telerik:RadDatePicker>
                                  <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Please enter Valid From." ControlToValidate="RadDatePicker_ValidFrom"></asp:RequiredFieldValidator>
                              </td>
                              </tr>
                               
                              <tr>
                              <td align="left" valign="top" class="style6">Valid Till<br />
                                  </td>
                              <td align="left" valign="top" class="table_content">
                                  <telerik:RadDatePicker ID="RadDatePicker_ValidTill" Runat="server" 
                                      Culture="en-US" MinDate="1/1/1900">
 
                                  </telerik:RadDatePicker>
                                  <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please enter Valid Till." ControlToValidate="RadDatePicker_ValidTill"></asp:RequiredFieldValidator>
                                  <asp:CompareValidator ID="dateCompareValidator" runat="server" ControlToValidate="RadDatePicker_ValidTill" ControlToCompare="RadDatePicker_ValidFrom"
                                    Operator="GreaterThanEqual" Type="Date" ErrorMessage="Valid Till date must be equal or greater than Valid From date - please correct dates." Display="Dynamic">
                                </asp:CompareValidator>
                              </td>
                              </tr>
                               
                              </table>
                              <br />
                                  <br />
                                  License Obtained<br />
                                  <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="LDS_License"
                                      AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" PageSize="20"
                                      CellSpacing="0" GridLines="None" Width="1000">
                                <MasterTableView DataSourceID="LDS_License" AutoGenerateColumns="False" DataKeyNames="License_To_Operate_ID" OverrideDataSourceControlSorting="true">
                                <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
                                <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                                <HeaderStyle Width="20px"></HeaderStyle>
                                </RowIndicatorColumn>
 
                                <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                                <HeaderStyle Width="20px"></HeaderStyle>
                                </ExpandCollapseColumn>
 
                                    <Columns>
 
                                        <telerik:GridBoundColumn DataField="db_dictionary_license.license_type"
                                            FilterControlAltText="Filter License_Number column" HeaderText="License Type"
                                            SortExpression="db_dictionary_license.license_type" UniqueName="license_type">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="db_dictionary_license.license_name"
                                            FilterControlAltText="Filter License Name column" HeaderText="License Name"
                                            SortExpression="db_dictionary_license.license_name" UniqueName="license_name">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="License_Number"
                                            FilterControlAltText="Filter License_Number column" HeaderText="License Number"
                                            SortExpression="License_Number" UniqueName="License_Number">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="License_Issuer"
                                            FilterControlAltText="Filter License_Issuer column" HeaderText="License Issuer"
                                            SortExpression="License_Issuer" UniqueName="License_Issuer">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Valid_From" DataType="System.DateTime"
                                            FilterControlAltText="Filter Valid_From column" HeaderText="Valid From"
                                            SortExpression="Valid_From" UniqueName="Valid_From" DataFormatString="{0: dd-MMM-yyy}">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Valid_Till" DataType="System.DateTime"
                                            FilterControlAltText="Filter Valid_Till column" HeaderText="Valid Till"
                                            SortExpression="Valid_Till" UniqueName="Valid_Till" DataFormatString="{0: dd-MMM-yyy}">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Issue_date" DataType="System.DateTime"
                                            FilterControlAltText="Filter Issue_date column" HeaderText="Issue Date"
                                            SortExpression="Issue_date" UniqueName="Issue_date" DataFormatString="{0: dd-MMM-yyy}">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="License_ID" Display="false"
                                            FilterControlAltText="Filter License_ID column" HeaderText="License_ID"
                                            UniqueName="License_ID" AllowFiltering="false" >
                                        </telerik:GridBoundColumn>
 
                                    </Columns>
 
                                <EditFormSettings>
                                <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                </EditFormSettings>
 
                                <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
                                </MasterTableView>
 
                                <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
 
                                <FilterMenu EnableImageSprites="False"></FilterMenu>
                                                                  </telerik:RadGrid>
                                                                  <asp:LinqDataSource ID="LDS_License" runat="server" EntityTypeName=""
                                                                      ContextTypeName="dcLRDBDataContext" TableName="db_Employee_Licenses"
                                                                      Where="UserID == @UserID && tmpRecord != @tmpRecord">
                                                                      <WhereParameters>
                                                                          <asp:QueryStringParameter Name="UserID" QueryStringField="UserID"
                                                                              Type="Int32" />
                                                                          <asp:Parameter DefaultValue="Y" Name="tmpRecord" Type="Char" />
                                                                      </WhereParameters>
                                                                  </asp:LinqDataSource>
 
                                                                  <br /><br /><br />
                                                                  Existing SIMPER Card<br />
                                                                  <telerik:RadGrid ID="RadGrid2" runat="server" AllowFilteringByColumn="True"
                                                                      AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"  OnItemCreated="RadGrid2_ItemCreated"
                                                                      CellSpacing="0" DataSourceID="LDS_SIMPER" GridLines="None" Width="400" onitemcommand="RadGrid2_ItemCommand">
                                                                      <ClientSettings EnablePostBackOnRowClick="true">
                                            <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" /> 
                                        </ClientSettings>
 
                                <MasterTableView DataKeyNames="SIMPER_ID" DataSourceID="LDS_SIMPER">
                                <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
                                <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                                <HeaderStyle Width="20px"></HeaderStyle>
                                </RowIndicatorColumn>
 
                                <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                                <HeaderStyle Width="20px"></HeaderStyle>
                                </ExpandCollapseColumn>
 
                                    <Columns>
                                                <telerik:GridTemplateColumn UniqueName="TemplateEditColumn" AllowFiltering="false">
                                                    <ItemTemplate>
                                                        <asp:HyperLink ID="ViewLink" runat="server" Text="View"></asp:HyperLink>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                        <telerik:GridBoundColumn DataField="Valid_From" DataType="System.DateTime"
                                            FilterControlAltText="Filter Valid_From column" HeaderText="Valid From"
                                            SortExpression="Valid_From" UniqueName="Valid_From" DataFormatString ="{0: dd-MMM-yyyy}">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Valid_Till" DataType="System.DateTime"
                                            FilterControlAltText="Filter Valid_Till column" HeaderText="Valid Till"
                                            SortExpression="Valid_Till" UniqueName="Valid_Till" DataFormatString ="{0: dd-MMM-yyyy}">
                                        </telerik:GridBoundColumn>
                                    </Columns>
 
                                <EditFormSettings>
                                <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                </EditFormSettings>
 
                                <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
                                </MasterTableView>
 
                                <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
 
                                <FilterMenu EnableImageSprites="False"></FilterMenu>
                                                                  </telerik:RadGrid>
 
                                        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
                                        <Windows>
                                            <telerik:RadWindow ID="SIMPER_PDF" runat="server" Title="View SIMPER Card" Height="700px"
                                                Width="710px" Left="50px" ReloadOnShow="true" ShowContentDuringLoad="false" VisibleStatusBar="false"
                                                Modal="false">
                                            </telerik:RadWindow>
                                        </Windows>
                                        </telerik:RadWindowManager>
 
                                                                  <asp:LinqDataSource ID="LDS_SIMPER" runat="server"
                                                                      ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                                                                      TableName="db_Employee_Simper_Records" Where="UserID == @UserID and parent_id == null">
                                                                      <WhereParameters>
                                                                          <asp:QueryStringParameter Name="UserID" QueryStringField="UserID"
                                                                              Type="Int32" />
                                                                      </WhereParameters>
                                                                  </asp:LinqDataSource>
                                                                  <br />
 
                                                              </div>
 
                                       </div>
                                       </asp:Content>

Code Behind

Imports Telerik.Web.UI
Imports System.Collections
Imports System
 
Partial Class TrainingAdmin_SIMPER_details
    Inherits System.Web.UI.Page
    Private Shared prevPage As String = String.Empty
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            prevPage = Request.UrlReferrer.ToString()
            If Request.QueryString("UserID") <> String.Empty Then
                Dim dc As New dcLRDBDataContext
                Dim res = (From a In dc.db_Employee_Details _
                           Where a.UserID = Request.QueryString("UserID").ToString _
                           From b In dc.db_Departments _
                           .Where(Function(fb) fb.DeptID = a.Dept_ID) _
                           .DefaultIfEmpty() _
                           Select New With { _
                               a.Employee_Display_Name, b.Department, a.Employee_ID, a.Gender, a.Photo _
                                                                  } _
                           ).FirstOrDefault
 
                If Not IsNothing(res) Then
                    lb_name.Text = res.Employee_Display_Name
                    lb_dept.Text = res.Department
                    lb_gender.Text = res.Gender
                    If Not IsNothing(res.Photo) Then
                        RadBinaryImage1.DataValue = res.Photo.ToArray
                    End If
                End If
 
                'Dim res2 = (From a In dc.db_Dictionary_Licenses Where a.License_ID = Request.QueryString("LicenseID").ToString).FirstOrDefault
                'If Not IsNothing(res2) Then
                '    lb_license.Text = res2.License_Name
                'End If
 
                'staff_photo.Src = ConfigurationManager.AppSettings("PhotoPath") & GetEmployeeIDByUserID(Request.QueryString("UserID")).ToString & ".jpg"
                'If System.IO.File.Exists(Server.MapPath(staff_photo.Src)) = True Then
                '    staff_photo.Src = staff_photo.Src
                'Else
                '    staff_photo.Src = ConfigurationManager.AppSettings("PhotoPath") & "/blank_staff_photo.jpg"
                'End If
 
                dc.Dispose()
 
            End If
        End If
    End Sub
    Protected Sub rtbMenu_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles rtbMenu.ButtonClick
        If e.Item.Value = "Back" Then
            Response.Redirect(prevPage)
            'Response.Redirect("~/TrainingAdmin/SIMPER.aspx")
        ElseIf e.Item.Value = "Create" Then
            If CreateSIMPER() = True Then
                Response.Redirect("~/TrainingAdmin/SIMPER_details.aspx?UserID=" & Request.QueryString("UserID"))
            Else
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "alert('Error! SIMPER Card cannot create.');", True)
            End If
        ElseIf e.Item.Value = "Preview" Then
            Dim url = "~/TrainingAdmin/SIMPER_view.aspx?SIMPER_ID=0&UserID=" & Request.QueryString("UserID") _
                      & "&From=" & RadDatePicker_ValidFrom.SelectedDate & "&To=" & RadDatePicker_ValidTill.SelectedDate
            'ScriptManager.RegisterStartupScript(Page, GetType(Page), "OpenWindow", _
            '                                    "window.open('" & url & "','_blank','status=0,toolbar=0,menubar=0,location=0,scrollbars=0,resizable=0,width=710,height=700');", True)
 
            Dim windowManager As New RadWindowManager()
            Dim window1 As New RadWindow()
            ' Set the window properties  
            window1.NavigateUrl = url
            window1.ID = "RadWindow1"
            window1.Height = 750
            window1.Width = 740
            window1.Top = 140
            window1.Left = 250
 
            window1.AutoSize = False
            window1.VisibleTitlebar = True
            window1.VisibleStatusbar = False
            window1.VisibleOnPageLoad = True
            ' Set this property to True for showing window from code  
            windowManager.Windows.Add(window1)
            Me.Form.Controls.Add(window1)
 
        ElseIf e.Item.Value = "Refresh" Then
            Response.Redirect("~/TrainingAdmin/SIMPER_details.aspx?userID=" & Request.QueryString("UserID"))
 
        End If
    End Sub
 
    Protected Function CreateSIMPER() As Boolean
        Dim confirm As Boolean = False
        Dim dc As New dcLRDBDataContext
 
        Dim simperid As Integer = 0
 
        If RadGrid1.Items.Count > 0 Then
            Dim newRecord1 As New db_Employee_Simper_Record
 
            dc.db_Employee_Simper_Records.InsertOnSubmit(newRecord1)
            newRecord1.UserID = Request.QueryString("UserID").ToString
            newRecord1.Valid_From = RadDatePicker_ValidFrom.SelectedDate
            newRecord1.Valid_Till = RadDatePicker_ValidTill.SelectedDate
            newRecord1.Project_ID = HttpContext.Current.Session("SelectedPID").ToString
            newRecord1.LastUpdateDate = DateTime.Now
            newRecord1.LastUpdateBy = HttpContext.Current.Session("UserID")
            dc.SubmitChanges()
            simperid = newRecord1.SIMPER_ID
 
            For Each row As GridDataItem In RadGrid1.Items
                Dim lic_id As String = row("License_ID").Text
                Dim lic_no As String = row("License_Number").Text
                Dim lic_type As String = row("License_Type").Text
                Dim lic_name As String = row("license_name").Text
                Dim lic_issuer As String = row("License_Issuer").Text
                Dim lic_v_from As DateTime = row("Valid_From").Text
                Dim lic_v_till As DateTime = row("Valid_Till").Text
                Dim lic_issue_date As DateTime = row("Issue_date").Text
 
                dc.insertEmployeeSIMPER(simperid, Request.QueryString("UserID").ToString, HttpContext.Current.Session("SelectedPID").ToString, _
                                        lic_id, lic_no, lic_name, lic_type, lic_issuer, lic_v_from, lic_v_till, lic_issue_date,
                                        DateTime.Now, HttpContext.Current.Session("UserID").ToString)
            Next
 
            confirm = True
            dc.Dispose()
        Else
            confirm = False
        End If
 
        Return confirm
    End Function
 
    Protected Sub RadGrid1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.DataBound
        'No License obtained
        If RadGrid1.Items.Count = 0 Then
            rtbMenu.FindItemByValue("Preview").Enabled = False
        Else
            rtbMenu.FindItemByValue("Preview").Enabled = True
        End If
    End Sub
 
    Protected Sub RadGrid2_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs)
        If TypeOf e.Item Is GridDataItem Then
            Dim editLink As HyperLink = DirectCast(e.Item.FindControl("ViewLink"), HyperLink)
            editLink.Attributes("href") = "javascript:void(0);"
            editLink.Attributes("onclick") = [String].Format("return ShowSIMPER('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("SIMPER_ID"), e.Item.ItemIndex)
        End If
    End Sub
 
    Protected Sub RadGrid2_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs)
 
        If e.CommandName = "RowClick" Then
 
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
            'Dim strId1 As String = item.GetDataKeyValue("UserID").ToString()
            'Response.Redirect("~/TrainingAdmin/SIMPER_details.aspx?UserID=" & strId1)
 
            'Dim editLink As HyperLink = DirectCast(e.Item.FindControl("ViewLink"), HyperLink)
            item.Attributes("href") = "javascript:void(0);"
            item.Attributes("onclick") = [String].Format("return ShowSIMPER('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("SIMPER_ID"), e.Item.ItemIndex)
 
        End If
 
    End Sub
End Class


Maria Ilieva
Telerik team
 answered on 06 Aug 2013
3 answers
287 views
Hello,

I am trying to dynamically delete and all the items in a combobox and then reload it with new items. Here is the code,

function addNewItems(selectRef, optionsArray, valuesArray) 
{                   
var combo = document.getElementById("ddlVehicleMake_Input");                   
combo.get_items().clear();                   
for (var idx = 0; idx < optionsArray.length; idx++) {         
              if (valuesArray == "") 
{
                          var comboItem = new Telerik.Web.UI.RadComboBoxItem();
                          comboItem.set_text(optionsArray[idx]);
                          combo.trackChanges();
                          combo.get_items().add(comboItem);
                      } else {                           var comboItem = new Telerik.Web.UI.RadComboBoxItem();
                          comboItem.set_text(optionsArray[idx]);  
                         combo.trackChanges();
                          combo.get_items().add(comboItem);
                      }                   }                   
combo.commitChanges();               }

It fails at combo.get_items().clear(); throwing an error that method is not supported by the object. I think making the following reference should be enough.
Am I missing any references? OR how do I go about it?

Thanks!

Nencho
Telerik team
 answered on 06 Aug 2013
1 answer
282 views
Hi,

I am trying to avoid same file being selected more than one time. I have seen posts and replies such as
http://www.telerik.com/community/forums/aspnet-ajax/async-upload/avoid-duplicate-in-asyncupload-multiple-drag-and-drop.aspx
but when multiple file is selected (not drag/drop but selection from file dialog) all those functions are failing. Mostly, they miss the duplicate item at index 0. I have tried many other ways but could not figure out a solid and reliable way to achieve this.

Please note that I am also handling the file removed event and do some external stuff there, and I either need to find a way for one the scenarios below: 

* catch and cancel duplicates when file is selected (before uploading etc.), in which case I do not need the file removed handler (since file was not actually selected, it was cancelled) 

or

* catch duplicates at files uploaded event, and remove them from file list, properly calling file removed event

When single file is selected, previously suggested functions work fine, but when 6-8 files selected, problems show up.

Please advise.

Thanks.
Hristo Valyavicharski
Telerik team
 answered on 06 Aug 2013
1 answer
115 views
I downloaded and studied the example for implementing a DBContentProvider for the RadFileExplorer. Afterwards I decided to try my hand at it but have run into an issue that has me at a loss. When I add a subfolder to my root the file editor throws a generic windows.alert error messasge that simply displays the subfolder path. After dismissing the alert the file editor will refresh with the subfolder appearing in the right-hand grid...but it does not appear as a child node of the root in the treeview. If I click the 'refresh' button then everything is fine...the subfolder appears in both the treeview, as a child node of the root, and in the grid.

I opened both the example and my project in VS and set a breakpoints in the 'ResolveRootDirectoryAsTree' method of each. Running the repro steps I discovered that in my implementation the breakpoint is hit twice...once before the alert message box and a second after dismissing. Both times the path argument is 'Root/'. The same operation on the example code has the breakpoint being hit four times...
'Root/'
'Root/NewFolder/'
'Root/'
'Root/'

A close look at the 'DirectoryItem' generated in the method shows no differences...the full path and location properties of both the parent and it's child are the same for both my code and Teleriks. Tracing through the code shows nothing different either. So my question is this...where in the telerik code-base is this alert message being generated and what error condition is it intended to convey??

it is a standard window.alert message box with a title of "Message from webpage" and a subject of "Root/NewFolder/"...that's it, no error message, just the full path of the newly added subfolder.

BTW: to setup for debugging the issue I deleted all the example 'Items' but the root folder. Also my implementation uses LinqToSql to manage two tables...dbo.Directory and dbo.Content, rather than a single 'Items' table as the example does. For that reason posting code with this thread would be pointless.

Has anyone else seen this error dialog being thrown when adding a folder?? If so, any suggestions as to where to look??
-mark


Vessy
Telerik team
 answered on 06 Aug 2013
1 answer
181 views
Hi All,

I am using RadGrid control and creating one grid column programmatically but the problem is that when I use filter of that column it gives me an error radgrid is neither a DataColumn nor a DataRelation for table. I can view that column but when I try to filter the records using the date filter then it produces an error.

Also, how can I set the index of that column as I want to set the position of that column as number three because before that I have two more columns edit and delete.

Any help would be greatly appreciated.

Thanks in advance.


<telerik:RadGrid ID="rgList" Width="100%" AllowFilteringByColumn="true" Skin="Metro"
        CssClass="table table-bordered" AutoGenerateDeleteColumn="false" AutoGenerateEditColumn="false"
        EnableEmbeddedBaseStylesheet="true" AllowSorting="True" AllowPaging="false" PageSize="10"
        ShowHeader="true" runat="server" AutoGenerateColumns="true" ShowStatusBar="true">
        <MasterTableView TableLayout="Auto" CommandItemDisplay="Top">
            <CommandItemSettings ShowRefreshButton="false" ShowAddNewRecordButton="false" ShowExportToCsvButton="true"
                ShowExportToExcelButton="true" />
        </MasterTableView>
        <GroupingSettings CaseSensitive="false" />
    </telerik:RadGrid>
 
 
 Protected Sub rgList_ColumnCreated(ByVal sender As Object, ByVal e As GridColumnCreatedEventArgs) Handles rgList.ColumnCreated
 
        If e.Column.UniqueName = "AutoGeneratedDeleteColumn" Then 'auto generated delete column id
            Dim gridButtonColumn As GridButtonColumn = e.Column
            gridButtonColumn.ConfirmText = Constants.DELETE_CONFIRM_MESSAGE
        ElseIf e.Column.UniqueName = Constants.EDIT Then
            TryCast(e.Column, GridBoundColumn).AllowFiltering = False
            TryCast(e.Column, GridBoundColumn).HeaderText = ""
        ElseIf e.Column.UniqueName = Constants.DELETE Then 'hiding Delete column from database
            e.Column.Visible = False
        ElseIf e.Column.UniqueName.Contains("_") Then
            Dim sColType As String = e.Column.UniqueName.Split("_")(1)
            If sColType = "GridDateTimeColumn" Then
                Dim _GridDateTimeColumn As New GridDateTimeColumn
                _GridDateTimeColumn.DataField = e.Column.UniqueName
                _GridDateTimeColumn.HeaderText = "Callback Date"
                _GridDateTimeColumn.EnableRangeFiltering = True
                _GridDateTimeColumn.AutoPostBackOnFilter = True
                rgList.MasterTableView.Columns.Add(_GridDateTimeColumn)
            End If
        Else
            e.Column.AutoPostBackOnFilter = True
            e.Column.CurrentFilterFunction = GridKnownFunction.Contains 'setting filter for all other columns
        End If
 
    End Sub
 
Andrey
Telerik team
 answered on 06 Aug 2013
1 answer
371 views
Hi team,
Language : vb.net
I tried search in your forum and all the examples given. Most of them, only show in c# not in vb.net.
And the function for onclick is not available ..except oncheckedchanged.
My problem is.
I have a checkbox column in Radgrid and only one must be selected. If more than that it will show an error in textbox.

One more case :
If i use GridClientSelectColumn, how to add a function like on checkedchanged.

Can somebody guide me.
Thanks.
Angel Petrov
Telerik team
 answered on 06 Aug 2013
5 answers
231 views
Hi folks

Anyone know whether this control support optgroups as in html?

Thanks
Merin
Shinu
Top achievements
Rank 2
 answered on 06 Aug 2013
2 answers
76 views
Hello Everyone,

I want to keep my Filtered ,Pagged , Sorted data as it is untill i m not logged out from my application

currently i bind my grid using NeedData-source .
and also that will not affect my performance also.

Can anyone have any idea or source for that?
Thanks,
Kiresh
Top achievements
Rank 1
 answered on 06 Aug 2013
1 answer
143 views
Hi

I have updated my RadControls to the latest version and now the visual studio Design mode is not working. Whatever Radcontrols are added to the page I am getting an Error rendering controls shown in red. Wondering how type casting error can happen in Design mode that too on updating the controls.

Thanks,
Damian
Shinu
Top achievements
Rank 2
 answered on 06 Aug 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?