Telerik Forums
UI for ASP.NET AJAX Forum
12 answers
1.7K+ views

We use your RadWindow controls quite a bit in our application. They are invoked using the following JavaScript convention…

 

var oWnd = radopen("EditWBSEast.aspx", "WBSRadWindow");

oWnd.setSize(830,300);

oWnd.Center();

 

We define WBSRadWindow as follows:

 

<telerik:RadWindowManager

    ID="RadWindowManager1"

    runat="server"

    Behavior="None"

    InitialBehavior="None" Left=""

    Skin="Outlook"

    style="display: inline;"

    Top=""

    DestroyOnClose="True">

    <Windows>

        <telerik:RadWindow

            ID="WBSRadWindow"

            Modal="true"

            runat="server"

            Behavior="None"

            DestroyOnClose="True"

            InitialBehavior="None"

            Title="”

            ReloadOnShow="true"

            Left=""

            NavigateUrl=""

            style="display: inline"

            Top=""

            Behaviors="None"  

            OnClientShow="OnClientShow">

        </telerik:RadWindow>

    </Windows>

</telerik:RadWindowManager>

 

This code provides us with a rather generic window with very little functionality but vastly better looking than the corresponding Window(Open) or Javascript alert. Our one problem is that we would also like to suppress the horizontal and vertical scrollbars.

 

We have seen elsewhere in your documentation that a JavaScript method similar to the one below should accomplish this

 

    function OnClientShow(radWindow)  

    {   

 

       var delScrollbar = radWindow._name;

       document.getElementsByName(delScrollbar)[0].setAttribute("scrolling", "no");

 

 

       var oTop = document.documentElement.scrollTop;  

       document.documentElement.scroll = "no";  

       document.documentElement.style.overflow = "hidden";  

       document.documentElement.scrollTop = oTop;  

 

       if(document.documentElement && document.documentElement.scrollTop)  

       {  

           var oTop = document.documentElement.scrollTop;  

           document.documentElement.scroll = "no";  

           document.documentElement.style.overflow = "hidden";  

           document.documentElement.scrollTop = oTop;  

                

       }

       else if(document.body)  

       {  

            var oTop = document.body.scrollTop;  

            document.body.scroll = "no";  

            document.body.style.overflow = "hidden";  

            document.body.scrollTop = oTop;  

        }  

    }  

  

This method does not suppress the scrollbars for us. Could you advise us as to how to best accomplish this?

 

 

Thanks

 

 

 

 

 

John
Top achievements
Rank 1
 answered on 19 Feb 2015
1 answer
100 views
I've been fighting with this issue for hours and hours now and I'm about ready to throw Rad controls out the window, it's so counter-intuitive.

I have a Radgrid called MyGroupsRadGrid01.  This grid displays a list of groups I'm in.  When I click on the Edit command of one of the rows, it displays the details of the group as well as a RadGrid of the other members in the group called GroupMembersRadGrid all within a FormTemplate.  I want to be able to add or delete an entry in GroupMembersRadGrid using GroupMemberRadGrid_DeleteCommand() and GroupMemberRadGrid_InsertCommand().  I tried using GroupMemberRadGrid_NeedDataSource() but the method itself cannot find GroupMemberRadGrid.  I then tried populating GroupMemberRadGrid within MyGroupsRadGrid01_ItemDataBound but after deleting an entry, the GroupMemberRadGrid showed up as empty (which seems to me necessitate's the GroupMemberRadGrid_NeedDataSource() that I can't get to work.  

<telerik:RadGrid ID="MyGroupsRadGrid01" runat="server"
    OnNeedDataSource="MyGroupsRadGrid01_NeedDataSource"
    AutoGenerateColumns="false" AutoPostBackOnFilter="true" OnUpdateCommand="MyGroupsRadGrid01_UpdateCommand" OnItemDataBound="MyGroupsRadGrid01_ItemDataBound"
    AllowSorting="true" AllowAutomaticUpdates="True" AllowAutomaticInserts="True" OnEditCommand="MyGroupsRadGrid01_EditCommand"
    AllowFilteringByColumn="false" MasterTableView-CommandItemDisplay="Top">
    <MasterTableView DataKeyNames="BWGroupID">
        <EditFormSettings EditFormType="Template">
            <FormTemplate>
                <table id="Table1" style="margin-left: 50px;" width="100%" cellspacing="2" cellpadding="1" border="0" rules="none" style="border-collapse: collapse;">
                    <tr>
                        <td valign="top">
                            <table id="Table2" cellspacing="2" cellpadding="1" border="0" rules="none" style="border-collapse: collapse;">
                                <tr id="BWGroupIDRow" runat="server">
                                    <td>BW Group ID   </td>
                                    <td><asp:Label ID="BWGroupIDLabel" runat="server" Text='<%# Bind("BWGroupID") %>' /></td>
                                </tr>
                                <tr id="BWGroupNameRow" runat="server">
                                    <td>BW Group Name   </td>
                                    <td><asp:Label ID="Label5" runat="server" Text='<%# Bind("BWGroupName") %>' /></td>
                                </tr>
                                <tr id="BWUserIDRow" runat="server">
                                    <td>BW User ID Owner   </td>
                                    <td><asp:Label ID="Label6" runat="server" Text='<%# Bind("BWUserOwner.BWUserID") %>' /></td>
                                </tr>
                                <tr id="DisplayNameRow" runat="server">
                                    <td>BW User Owner   </td>
                                    <td><asp:Label ID="Label7" runat="server" Text='<%# Bind("BWUserOwner.DisplayName") %>' /></td>
                                </tr>
                                <tr id="IsActive" runat="server">
                                    <td></td>
                                    <td><asp:CheckBox ID="DeactivateCheckBox" runat="server" Text="Deactivate" /></td>
                                </tr>
                                <tr>
                                    <td align="center" colspan="2"><br />
                                        <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                            runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button
                                        <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button>
                                    </td>
                                </tr>
                            </table>
 
                        </td>
                        <td valign="top">
                            <table id="Table3" style="margin-left: 5px;" cellspacing="2" cellpadding="1" border="0" rules="none" style="border-collapse: collapse;">
                                <tr><td><h4>Group Members:</h4></td></tr>
                                <tr>
                                    <td>
                                        <telerik:RadGrid ID="GroupMemberRadGrid" runat="server" width="100%" AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
                                            AllowAutomaticDeletes="true" OnDeleteCommand="GroupMemberRadGrid_DeleteCommand" OnNeedDataSource="GroupMemberRadGrid_NeedDataSource"
                                            AutoPostBackOnFilter="true" OnUpdateCommand="GroupMemberRadGrid_UpdateCommand">
                                            <MasterTableView AutoGenerateColumns="False" DataKeyNames="BWUserId">
                                                <Columns>
                                                    <telerik:GridBoundColumn DataField="BWGroupId" DataType="System.Int32" HeaderText="Group ID" ReadOnly="True" SortExpression="BWGroupId" UniqueName="BWGroupId"></telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="BWUserId" DataType="System.Int32" HeaderText="User ID" ReadOnly="True" SortExpression="BWUserId" UniqueName="BWUserId"></telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="DisplayName" HeaderText="Name" SortExpression="DisplayName" UniqueName="DisplayName"></telerik:GridBoundColumn>
                                                    <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton" />
                                                </Columns>
                                            </MasterTableView>
                                        </telerik:RadGrid>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                <br />
            </FormTemplate>
        </EditFormSettings>
        <Columns>
            <telerik:GridEditCommandColumn ButtonType="LinkButton" EditText="View/Edit" UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn>
            <telerik:GridBoundColumn UniqueName="BWGroupID" DataField="BWGroupID" HeaderText="BW Group ID" SortExpression="BWGroupID" FilterControlWidth="150px" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="BWGroupName" HeaderText="BW Group Name" ReadOnly="true" SortExpression="BWGroupName" FilterControlWidth="150px" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="BWUserOwner.BWUserID" HeaderText="BW User ID Owner" SortExpression="BWUserOwner.BWUserID" FilterControlWidth="50px" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="BWUserOwner.DisplayName" HeaderText="BW User Owner" SortExpression="BWUserOwner.DisplayName" FilterControlWidth="50px" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"></telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
protected void MyGroupsRadGrid01_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem editedItem = e.Item as GridEditableItem;
        Label BWGroupID = editedItem.FindControl("BWGroupIDLabel") as Label;
        int ParseBWGroupID = -1; int.TryParse(BWGroupID.Text, out ParseBWGroupID);
 
        if (ParseBWGroupID < 1)
            return;
 
        BWGroupUsers usersInGroup = new BWGroupUsers();
        usersInGroup.GetActiveBWUsersByGroupID(ParseBWGroupID);
 
        RadGrid GroupMemberRadGrid = new RadGrid();
        GroupMemberRadGrid = (RadGrid)e.Item.FindControl("GroupMemberRadGrid");
 
        ViewState["BWGroupID"] = ParseBWGroupID;
 
        //GroupMemberRadGrid.DataSource = usersInGroup.BWGroupUsersList.OrderBy(u => u.DisplayName);
        //GroupMemberRadGrid.DataBind();
    }
}
 
protected void GroupMemberRadGrid_DeleteCommand(object sender, GridCommandEventArgs e)
{
    if (e.Item is GridDataItem && e.CommandName == "Delete")
    {
        GridDataItem item = (GridDataItem)e.Item;
        int parseGroupId = -1; int.TryParse(item["BWGroupId"].Text.ToString(), out parseGroupId);
        int parseUserId = -1; int.TryParse(item["BWUserId"].Text.ToString(), out parseUserId);
 
        BWGroupUser selectedGroupUser = new BWGroupUser();
        //selectedGroupUser.DeleteBWGroupUser(parseGroupId, parseUserId);
    }
}
 
protected void GroupMemberRadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    GroupMemberRadGrid.DataSource = GroupMemberDataSource().BWUserList;  //Doesn't find this!
}
 
private BWUsers GroupMemberDataSource()
{
    BWUsers allBWUsers = new BWUsers();
    if (ViewState["BWGroupID"] != null && ViewState["BWGroupID"].ToString().Length > 0)
    {
        int ParseBWGroupID = -1; int.TryParse(ViewState["BWGroupID"].ToString(), out ParseBWGroupID);
 
        allBWUsers.GetActiveBWUsersByGroupID(ParseBWGroupID);
        return allBWUsers;
    }
    return allBWUsers;
}



It's 9:00pm and I've been working on this since noon.  I can't fight with this all night and it's due in 11 hours.  I need help.
Pavlina
Telerik team
 answered on 19 Feb 2015
5 answers
94 views
Data in the file exported to excel is incorrect plz help me
Kostadin
Telerik team
 answered on 19 Feb 2015
1 answer
101 views
After hours of research, I have figured out my own solution to some issues I reported earlier. So to summarize all my issues and solutions:

I experienced two major BINDING issues with fields under <EditFormSettings EditFormType="Template"><FormTemplate>:

1. DropDownList - Setting the SelectedValue property to <%# Bind("security_webpage_id") %> caused an error when clicking on the Add New Record button. The error was 'ddlWebPages' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value.

Fix: I added a blank listitem. My Dropdown tag looked like this after fix:

<asp:DropDownList ID="ddlWebPages" DataSourceID='sqlDataSourceWebpages'
                                               AppendDataBoundItems="True" DataTextField="webpage_name" DataValueField="ID"
                                               SelectedValue='<%# Bind("security_webpage_id") %>' runat="server"> 
                                      <asp:ListItem Text=" " Value=""></asp:ListItem>
                                          
</asp:DropDownList>
 
2. Checkbox - I had three checkboxes that received an error when I clicked on the Add New Record button.
The error was "Specified cast is not valid".

Fix: I created a User Control for the CheckBox and handled the passing of null value to the Checked property which is what was happening when the Add New Record button was clicked. Below is my code for the code behind and markup of the checkbox control.

Code-Behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace FRC
{
    public partial class CheckBoxNullableChecked : System.Web.UI.UserControl
    {
        private bool m_checked = false;
        protected void Page_Load(object sender, EventArgs e)
        {
            m_checked = CheckBox1.Checked;
        }
 
        public object Checked
        {
            get { return m_checked; }
            set
            {
                if (value.GetType() == DBNull.Value.GetType()) m_checked = false;
                else if (value == null) m_checked = false;
                else if (value.GetType() == typeof(bool)) m_checked = (bool)value;
                else m_checked = false;
            }
        }
        public string Text
        {
            get { return this.CheckBox1.Text; }
            set { this.CheckBox1.Text = value; }
        }
 
        protected void Page_PreRender()
        {
            CheckBox1.Checked = m_checked;
        }
 
    }
}



Mark-up:
%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CheckBoxNullableChecked.ascx.cs" Inherits="FRC.CheckBoxNullableChecked" %>
<asp:CheckBox ID="CheckBox1" runat="server" />


Registering User Control in markup file that contains the standard Checkbox;
<%@ Register src="~/CheckBoxNullableChecked.ascx" TagName="CheckBoxNullableChecked"
    TagPrefix="uc1" %>

Your Checkbox and/or Drop Down List will look like this now under the FormTemplate:
<EditFormSettings EditFormType="Template">
               <FormTemplate>   
                   
                  
                   <div id="divGridEdit" class="divGrid">
                           <b>Add New Role to Webpage Association</b>
                           <br /><br />
                           <table>
 
                               <tr>
                                   <td><asp:Label Text="Web Page:" runat="server"></asp:Label></td>
                                   <td>
                                      <asp:DropDownList ID="ddlWebPages" DataSourceID='sqlDataSourceWebpages'
                                              AppendDataBoundItems="True" DataTextField="webpage_name" DataValueField="ID"
                                              SelectedValue='<%# Bind("security_webpage_id") %>' runat="server">
                                     <asp:ListItem Text=" " Value=""></asp:ListItem>
                                          
                                        </asp:DropDownList>
 
 
                                   </td>
                               </tr>
                               
                               <tr>
                                   <td><br /></td>
                                   <td></td>
                               </tr>
                               <tr>
                                    <td><asp:Label Text="Allow Add:" runat="server"></asp:Label></td>
                                    <td><uc1:CheckBoxNullableChecked ID="chkboxAllowAdd" Checked='<%# Bind("add_privledge") %>' runat="server" />
                                    </td>
                               </tr>
                               <tr>
                                    <td><asp:Label Text="Allow Edit:" runat="server"></asp:Label></td>
                                    <td><uc1:CheckBoxNullableChecked ID="chkboxAllowEdit" Checked='<%# Bind("edit_privledge") %>' runat="server" />
                                    </td>
                               </tr>
                               <tr>
                                    <td><asp:Label Text="Allow Delete:" runat="server"></asp:Label></td>
                                    <td><uc1:CheckBoxNullableChecked ID="chkboxAllowDelete" Checked='<%# Bind("delete_privledge") %>' runat="server" /></td>
                               </tr>
 
                               <tr>
                                   <td><asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                       CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'  runat="server" /></td>
                                   <td><asp:Button ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" CausesValidation="false" /></td>
                               </tr>
                           </table>
                       </div>            
 
               </FormTemplate>
           </EditFormSettings>
 
 
           </MasterTableView>
           <ClientSettings>
               <ClientEvents OnRowDblClick="rowDblClick" />
           </ClientSettings>
               
       </telerik:RadGrid>
 
 
   </div>
 
   <asp:SqlDataSource ID="sqlDataSourceWebpages" runat="server" SelectCommand="SELECT * FROM dbo.security_webpage" ConnectionString="<%$ ConnectionStrings:GATEConnectionString %>"></asp:SqlDataSource>

Hopefully this will help someone else not have to go through days of pain that I did over there two issues
Eyup
Telerik team
 answered on 19 Feb 2015
6 answers
688 views
Hi,

I get this error since I started to use Telerik controls a couple hours ago.

 JavaScript runtime error: Unable to get property 'UI' of undefined or null reference

The exception occurs on the following line:

   
$create(Sys.Extended.UI.ModalPopupBehavior, {"BackgroundCssClass":"modalBackground","DropShadow":true,"PopupControlID":"Pnl_ForAdd","dynamicServicePath":"/Main.aspx","id":"MdlPppXtndr_Add_ID"}, null, null, $get("DummyForAdd"));


One my page I use Ajax for the modal popups and update panels.
I did as people suggested in other posts, and used the design to register Telerik in the web.config as follow:

<system.web>
...
    <httpHandlers>
      <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
    </httpHandlers>
...
</system.web>

<system.webServer>
...
<handlers>
      <add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" />
</handlers>
...
</system.webServer>

<location path="Telerik.Web.UI.WebResource.axd">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>

On my page I register the scriptmanager like this:
           
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="True"></telerik:RadScriptManager>

So now I am at a loss about what to do to make this work, and in a hurry to get things working because of deadlines.
Marin Bratanov
Telerik team
 answered on 19 Feb 2015
3 answers
179 views
I'm using the EditMode="PopUp" and I have script that will center the popup window over the visible portion of the screen.  Except there's a hitch: I'm not explicitly setting the height of my popup but my script relies on knowing the height of the popup object.  How can I get the height if I don't explicitly set it?
Hassan
Top achievements
Rank 1
 answered on 19 Feb 2015
1 answer
103 views
No matter how I try I always end up with the first item in args.get_item below, in my example below one of the images should be hidden on row 4, but instead it hides it on row 1 no matter what I try, the data_item seem to be correct, item or findelement does not and I´m guessing I´m finding the element to hide in the wrong manner, any tips?


function RowDataBound(sender, args) {
var di = args.get_dataItem();
var item = args.get_item();
 
var sortUp = item.findElement('btnSortUp')
var sortDown = item.findElement('btnSortDown')
 //var sortUp = $(item).find("btnSortUp");
 //var sortDown = $(item).find("btnSortDown");
 
var pos = di.abdp_pos_no;
 
 if (pos == 1) {
 $(sortDown).hide();
 }
 if (pos == 4) {
 $(sortUp).hide();
 }
}


<telerik:GridTemplateColumn HeaderText="Sort" UniqueName="sort" SortExpression="abdp_pos_no" DataField="ben">
                <HeaderStyle HorizontalAlign="Right" />
                <ItemStyle HorizontalAlign="Right" />
                <ClientItemTemplate>
                    <img id="btnSortUp" src="images/copy.png" data-pos="#=abdp_pos_no #" data-way="-1" style="cursor:pointer;" onclick="reorder(this)"></img>
                    <img id="btnSortDown" src="images/copy.png" data-pos="#=abdp_pos_no #" data-way="+1" style="cursor:pointer;" onclick="reorder(this)"></img>
                </ClientItemTemplate>
            </telerik:GridTemplateColumn>





Angel Petrov
Telerik team
 answered on 19 Feb 2015
10 answers
1.3K+ views
Hi,

I am trying to insert and edit items in a RadGrid bound to an object datasource that is contained in a Web User Control.

I have an RadAjaxManagerProxy in the Web User Control to handle the AjaxRequests and we populate the data with objects in a collection class. The RadAjaxManagerProxy is configured so the ID of the RadGrid is set as the AjaxControlID and the ID of the RadGrid is also the AjaxUpdatedControl ControlID.

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">  
</telerik:RadAjaxLoadingPanel> 
 
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">  
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="RadGridContactDetails">  
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadGridContactDetails" LoadingPanelID="RadAjaxLoadingPanel1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManagerProxy> 

One of the columns in the RadGrid control is a GridDropDownColumn which is bound to an XmlDataSource.

I have a CommandItemTemplate which has one button in it that is used to add a new record to the underlying data object and the RadGrid.

<telerik:RadGrid AllowAutomaticInserts="true" AllowAutomaticDeletes="true" AllowAutomaticUpdates="true" ID="RadGridContactDetails"  runat="server" skinId="kcResourceOpener" width="100%" height="245" Visible="true" DataSourceID="dsContactDetails">  
    <MasterTableView ShowHeadersWhenNoRecords="true" EditMode="EditForms" EnableNoRecordsTemplate="true" PageSize="10" CommandItemDisplay="Top" DataKeyNames="Priority">   
        <CommandItemTemplate> 
            <table border="0" cellpadding="1" cellspacing="0" width="100%">  
                <tr> 
                    <td align="right">  
                        <asp:LinkButton id="btnAddRecord" runat="server" ForeColor="#00247d" CssClass="Btn" CommandName="InitInsert" Text="Add"></asp:LinkButton> 
                    </td> 
                </tr> 
            </table> 
        </CommandItemTemplate>          
        <NoRecordsTemplate> 
            No data available.  
        </NoRecordsTemplate> 
        <Columns> 
            <telerik:GridTemplateColumn HeaderText="" AllowFiltering="false" ItemStyle-Wrap="false" HeaderStyle-Width="75pt">  
                <ItemTemplate> 
                    <asp:LinkButton ID="btnEdit" runat="server" Text="Select" ForeColor="#00247d" Font-Underline="false" CssClass="Btn" CommandName="Edit" Enabled="<%# not me.IsReadOnly %>" /> 
                </ItemTemplate> 
                <ItemStyle Wrap="False" /> 
            </telerik:GridTemplateColumn> 
            <telerik:GridButtonColumn ButtonType="PushButton" UniqueName="btnUp" ButtonCssClass="Btn" CommandName="MoveUp" Text="Up" HeaderText="" HeaderStyle-Width="15%">  
            </telerik:GridButtonColumn> 
            <telerik:GridButtonColumn ButtonType="PushButton" UniqueName="btnDown" ButtonCssClass="Btn" CommandName="MoveDown" Text="Down" HeaderText="" HeaderStyle-Width="15%">  
            </telerik:GridButtonColumn> 
            <telerik:GridDropDownColumn UniqueName="Type" DataField="Type" ListTextField="Type" ListValueField="Type" DataSourceID="dsContactDetailTypes" HeaderText="Type" HeaderStyle-Width="20%">  
            </telerik:GridDropDownColumn> 
            <telerik:GridBoundColumn DataField="Detail" UniqueName="Detail" AllowFiltering="false" AllowSorting="false" HeaderText="Detail" HeaderStyle-Width="20%">  
            </telerik:GridBoundColumn> 
            <telerik:GridButtonColumn ButtonType="PushButton" ButtonCssClass="Btn" CommandName="Delete" Text="Delete" HeaderText="" HeaderStyle-Width="15%">  
            </telerik:GridButtonColumn>                                              
        </Columns> 
        <EditFormSettings EditFormType="Template" CaptionFormatString="Enter/Edit the type and value for this detail record:">  
            <PopUpSettings Width="450px" /> 
            <FormTemplate> 
              
                <table width="100%" border="0" cellpadding="2" cellspacing="0">  
                    <tr> 
                        <th align="left">Contact Details</th> 
                        <th colspan="2" align="right">  
                            <asp:LinkButton ID="btnSaveDetail" CssClass="Btn" ForeColor="#00247d" Font-Underline="false" runat="server" CommandName='<%# IIf(TypeOf Container is GridEditFormInsertItem, "PerformInsert", "Update") %>' Text="Save" /> 
                            <asp:LinkButton ID="btnCancelDetail" CssClass="Btn" ForeColor="#00247d" Font-Underline="false" runat="server" CommandName="Cancel" Text="Cancel" /> 
                        </th> 
                    </tr> 
                    <tr> 
                        <td class="Form_Label" align="right">Type:&nbsp;</td> 
                        <td style="width:300px;" colspan="2">  
                            <asp:DropDownList ID="dropDownDetailTypes" runat="server" DataSourceID="dsContactDetailTypes" DataTextField="Type" DataValueField="Type" Enabled='<%# not me.IsReadOnly %>'>  
                            </asp:DropDownList> 
                        </td> 
                          
                    </tr> 
                    <tr> 
                        <td class="Form_Label">Detail:&nbsp;</td> 
                        <td> 
                            <asp:TextBox ID="txtDetailText" runat="server" Text='<%# Bind("Detail") %>' Enabled='<%# not me.IsReadOnly %>' Width="300px"></asp:TextBox> 
                        </td> 
                        <td> 
                            &nbsp;  
                        </td> 
                    </tr> 
                    <tr><td colspan="3">&nbsp;</td></tr>  
                </table> 
            </FormTemplate> 
        </EditFormSettings> 
    </MasterTableView> 
</telerik:RadGrid> 
 
<asp:ObjectDataSource ID="dsContactDetails" runat="server" 
    SelectMethod="Find"   
    TypeName="SSI.KnowledgeCenter.ICKC.Resources.ContactDetailCollection" 
    DataObjectTypeName="SSI.KnowledgeCenter.ICKC.Resources.ContactDetailCollection">  
</asp:ObjectDataSource> 
 
<asp:XmlDataSource ID="dsContactDetailTypes" runat="server" DataFile="../App_Data/ContactDetailTypes.xml">  
</asp:XmlDataSource> 

I've followed all of the examples I can find related to inserting/updating/deleting items from the RadGrid control. I get the Edit Form to appear with the correct data if I use the Automatic Form, but if I use a FormTemplate to design my own form, I cannot set the SelectedValue property for the DropDownList. I receive an error saying that this property cannot be set declaratively. The example in the set of demos shows this property being set to the bound value in the column.

Using the Form Template that I designed, I process insert and update operations in the ItemCommand event handler. Here, I first test for the CommandName property. If it is equal to RadGrid.PerformInsertCommandName, I process it as an Insert. If it is a RadGrid.UpdateCommandName, then I process it as an Update:

Private Sub RadGridContactDetails_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGridContactDetails.ItemCommand  
        Select Case e.CommandName  
            Case RadGrid.InitInsertCommandName  
                ' Add button has been clicked:  
 
            Case RadGrid.UpdateCommandName  
                'e.Canceled = True  
                'Dim newVals As System.Collections.Specialized.ListDictionary = New System.Collections.Specialized.ListDictionary()  
                'newVals("Type") = Me.ContactDetails(e.Item.ItemIndex).Type  
                'newVals("Detail") = Me.ContactDetails(e.Item.ItemIndex).Detail  
                'e.Item.OwnerTableView.InsertItem(newVals)  
                Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)  
                Dim d As IContactDetail = Me.ContactDetails(e.Item.ItemIndex)  
                Dim dropDownDetailTypes As DropDownList = CType(editedItem.FindControl("dropDownDetailTypes"), DropDownList)  
                If dropDownDetailTypes IsNot Nothing Then d.Type = dropDownDetailTypes.SelectedItem.Text  
                Dim txtDetailText As TextBox = CType(editedItem.FindControl("txtDetailText"), TextBox)  
                If txtDetailText IsNot Nothing Then d.Detail = txtDetailText.Text  
 
            Case RadGrid.PerformInsertCommandName  
                Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)  
                Dim d As New ContactDetail(_ConfigName, ICKCUser.ProviderUserKey)  
                d.Priority = RadGridContactDetails.Items.Count + 1  
                Dim dropDownDetailTypes As DropDownList = CType(editedItem.FindControl("dropDownDetailTypes"), DropDownList)  
                If dropDownDetailTypes IsNot Nothing Then d.Type = dropDownDetailTypes.SelectedItem.Text  
                Dim txtDetailText As TextBox = CType(editedItem.FindControl("txtDetailText"), TextBox)  
                If txtDetailText IsNot Nothing Then d.Detail = txtDetailText.Text  
 
                Me.ContactDetails.Add(d) 

 

When I click the Save button on an Inserted Item, the DropDownList always shows the SelectedIndex = 0 instead of whatever selection is made. The TextBox control shows the Text property to be empty.

 

When I click the Save button on an Updated item, the DropDownList always shows the SelectedIndex to be whatever corresponds with the previous value of that property of the object. The TextBox control always shows the origjnal value for the associated property of the object.

 

I've also tried the Automatic EditForms and have also had no luck.  In the InsertCommand event handler, I have tried two approaches:

Private Sub RadGridContactDetails_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGridContactDetails.InsertCommand  
        Dim newDetailItem As Telerik.Web.UI.GridEditableItem = CType(e.Item, Telerik.Web.UI.GridEditableItem)  
        Dim newValues As Hashtable = New Hashtable()  
 
        Dim detail As IContactDetail = New ContactDetail(_ConfigName, ICKCUser.ProviderUserKey)  
        detail.Priority = RadGridContactDetails.Items.Count + 1  
        e.Item.OwnerTableView.ExtractValuesFromItem(newValues, newDetailItem)  
 
        Try  
            For Each entry As DictionaryEntry In newValues  
                Dim propertyName As String = entry.Key.ToString()  
                Dim propertyValue As String = entry.Value  
                Select Case propertyName  
                    Case "Type"  
                        detail.Type = propertyValue 
                    Case "Detail"  
                        detail.Detail = propertyValue 
                    Case Else  
                        Return  
                End Select  
 
                Me.ContactDetails.Add(detail)  
            Next  
        Catch ex As Exception  
            _Manager.Alert(ex.Message)  
        End Try  
    End Sub 

and also this approach:

    Private Sub RadGridContactDetails_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGridContactDetails.InsertCommand  
        Dim newItem As Telerik.Web.UI.GridEditableItem = CType(e.Item, Telerik.Web.UI.GridEditableItem)  
        Dim editMan As Telerik.Web.UI.GridEditManager = newItem.EditManager  
        Dim detail As IContactDetail = New ContactDetail(_ConfigName, ICKCUser.ProviderUserKey)  
        detail.Priority = RadGridContactDetails.Items.Count + 1  
 
        For Each column As Telerik.Web.UI.GridColumn In e.Item.OwnerTableView.Columns  
            If TypeOf column Is IGridEditableColumn Then  
                Dim editableCol As IGridEditableColumn = CType(column, IGridEditableColumn)  
 
                If editableCol.IsEditable Then  
                    Dim editor As IGridColumnEditor = editMan.GetColumnEditor(editableCol)  
                    Dim editorText As String = "unknown" 
                    Dim editorValue As Object = Nothing 
                    If (TypeOf editor Is GridTextColumnEditor) Then  
                        editorText = CType(editor, GridTextBoxColumnEditor).Text  
                        editorValue = CType(editor, GridTextColumnEditor).Text  
                    End If  
                    If (TypeOf editor Is GridBoolColumnEditor) Then  
                        editorText = CType(editor, GridBoolColumnEditor).Value.ToString()  
                        editorValue = CType(editor, GridBoolColumnEditor).Value  
                    End If  
                    If (TypeOf editor Is GridDropDownColumnEditor) Then  
                        editorText = CType(editor, GridDropDownColumnEditor).SelectedText  
                        editorValue = CType(editor, GridDropDownColumnEditor).SelectedValue  
                    End If  
                    Select Case column.UniqueName  
                        Case "Type"  
                            detail.Type = editorText 
                        Case "Detail"  
                            detail.Detail = editorText 
                        Case Else  
                            Return  
                    End Select  
                End If  
            End If  
        Next  
        Me.ContactDetails.Add(detail)  
    End Sub 

Neither approach has produced values from the EditForm for me. In both cases, I can get the name of the field, but not the value (in other words, I can find the column names but not the updated values).

I'm thinking this is an Ajax-related issue, but am unsure as to what is really going on here. I have placed a watch on the e.item object as it comes into the event handlers, but there are no values in the property reflecting the changes made on the EditForm. I see the controls, but not the associated values.

Any ideas would be very helpful at this point.

Thanks,

Charlie

David
Top achievements
Rank 1
 answered on 19 Feb 2015
3 answers
515 views
Hello,

I have this grid structure, in which the field is in the PlaceHolder only have to show the insertion of a new record.

<EditFormSettings EditFormType="Template">
                <EditColumn ButtonType="ImageButton" />
                <FormTemplate>
                    <table>
                        <tr>
                            <td>Nombre de usuario: </td>
                            <td>
                                <asp:TextBox ID="login" runat="server" Text='<%# Bind("Login") %>' />
                            </td>
                        </tr>
                        <asp:PlaceHolder ID="phInsert" runat="server">
                            <tr>
                                <td>Contraseña: </td>
                                <td>
                                    <asp:TextBox ID="password" runat="server" Text='<%# Bind("Password") %>' />
                                </td>
                            </tr>
                        </asp:PlaceHolder>
                        </tr>
                    </table>
                </FormTemplate>
            </EditFormSettings>

In code -behind I have the following:

protected void RadGridUserAccount_ItemCommand(object sender, GridCommandEventArgs e)
        {
            RadGrid grid = sender as RadGrid;

            if (e.CommandName == "InitInsert")
            {
                //var gridEditFormItem = e.Item as GridEditFormItem ?? ((GridDataItem)(e.Item)).EditFormItem;
                GridItem cmdItem = grid.MasterTableView.GetItems(GridItemType.CommandItem)[0];
                //GridEditFormItem editform = (GridEditFormItem)((Telerik.Web.UI.GridDataItem)(e.Item)).EditFormItem;
                PlaceHolder insert = cmdItem.FindControl("phInsert") as PlaceHolder;
                //GridEditFormItem gridEditFormItem = (GridEditFormItem)e.Item;

                //PlaceHolder insert = (PlaceHolder)gridEditFormItem.FindControl("phInsert");
               
                insert.Visible = true;
            }
        }

This code is not working for me, always return NullReferenceException.

Would appreciate help as I have tried in many ways and I always get the same exception.


Viktor Tachev
Telerik team
 answered on 19 Feb 2015
2 answers
102 views
Hi,

I am trying the new media player because we are interesting by Youtube Playlist functionnality.

I've just tried the example code but it doesn't work here.

When I look why it doesn't work, I can find this :

Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée 216.58.211.78:443
   à System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)


It's french but as you can guess, it just says that it cannot connect to the playlist (I've just copy-paste the demo code).

Have you any idea ?

Thanks in advance.
Arnaud
Top achievements
Rank 1
 answered on 19 Feb 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?