This is a migrated thread and some comments may be shown as answers.

How To Find Control Use in RadListBox1_Transferred

10 Answers 238 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mohamed
Top achievements
Rank 1
mohamed asked on 03 Jun 2011, 10:27 AM
Hello every one,


How to find control in ,
But One thing that radlist box in EditFormSettings,
That why how i find that controls.
Reply As soon As possible

 protected void RadListBoxSourceGroup_Transferred(object sender, Telerik.Web.UI.RadListBoxTransferredEventArgs e)
        {
            RadListBox SelectedList = (RadListBox)FindControl("RadListBoxDestinationGroup");
            foreach (RadListBoxItem item in SelectedList.Items)
            {
                Response.Write(item.Attributes["myId"]); // get the third value
            }
        }


Thanks,
Mohamed.

10 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Jun 2011, 10:52 AM
HI,

i am not able to get your exact requirement.
if possible than explain in detail or give some code.

Thanks,
Jayesh Goyani
0
Princy
Top achievements
Rank 2
answered on 03 Jun 2011, 10:56 AM
Hello Mohammed,

You can easily access RadListBoxDestinationGroup  ,which is in the EditForm, by using the sender property.
C#:
protected void RadListBoxDestinationGroup_Transferred(object sender, RadListBoxTransferredEventArgs e)
   {
       RadListBox listbox = sender as RadListBox;
 
   }

Hope this helps.
 
Thanks,
Princy.
0
mohamed
Top achievements
Rank 1
answered on 03 Jun 2011, 11:46 AM

Please See The Image,

1)  Available radlistbox values are in assigned in that sortcolumn radcombobox
how i assign this


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LayoutDialog.aspx.cs" Inherits="TBS_HelpDesk.Views.Assets.LayoutDialog" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .example-panel
        {
            background: transparent url(bg.jpg) no-repeat 0 0;
            position: relative;
            width: 748px;
            height: 383px;
        }
        #RadListBox1
        {
            position: absolute;
            top: 143px;
            left: 68px;
        }
        #RadListBox2
        {
            position: absolute;
            top: 143px;
            left: 304px;
        }
        #targetTextBox
        {
            left: 545px;
            position: absolute;
            top: 143px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadCodeBlock runat="server" ID="radCodeBlock">
        <script type="text/javascript">

            function onSelectedIndexChanged(sender, eventArgs) {
                debugger;
                updateComboBox(sender);
            }
            function updateComboBox(listBox) {
                var text = "";
                var value = "";
                var items = listBox.get_selectedItems();

                for (var i = 0; i < items.length; i++) {
                    var item = items[i];

                    //Check whether the Item's 'selected' attribute is set to true.
                    if (item.get_selected()) {
                        text += item.get_text() + ", ";
                        value += item.get_value() + ", ";
                    }
                }

                text = text.substring(0, text.length - 2);
                value = value.substring(0, value.length - 2);

                //var comboBox = $find("ComboBox_SortColumn");
                var comboBox = $find($("[id$='pnlAdd'] [id$='ComboBox_SortColumn']")[0].id);

                //Set the text of the RadComboBox to the texts of the selected Items, separated by ','.
                comboBox.set_text(text);

                //Set the value of the RadComboBox to values of the selected Items, separated by ','.
                comboBox.trackChanges();
                comboBox.get_items().getItem(0).set_value(value);
                comboBox.commitChanges();
            }

        </script>
    </telerik:RadCodeBlock>
    <div style="width: 600px; height: 500px;">
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" UpdatePanelHeight="" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadGrid ID="RadGrid1" runat="server" Skin="Office2007" OnNeedDataSource="RadGrid1_NeedDataSource"
            OnItemCommand="RadGrid1_ItemCommand" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
            GridLines="None" AutoCompleteType="Disabled" AllowFilteringByColumn="True" AllowPaging="True"
            AllowSorting="True" OnItemDataBound="RadGrid1_ItemDataBound">
            <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" EditMode="PopUp"
                EditFormSettings-PopUpSettings-Modal="true" IsFilterItemExpanded="false" ClientDataKeyNames="LayoutId,LayoutName">
                <CommandItemTemplate>
                    <telerik:RadToolBar ID="RadToolBar1" OnButtonClick="RadToolBar1_ButtonClick" runat="server">
                        <Items>
                            <telerik:RadToolBarButton Text="Add new" CommandName="InitInsert" ImageUrl="../../images/AddRecord.gif"
                                Visible='<%# !RadGrid1.MasterTableView.IsItemInserted %>'>
                            </telerik:RadToolBarButton>
                            <telerik:RadToolBarButton Text="Refresh" CommandName="RebindGrid" ImageUrl="../../images/Refresh.gif">
                            </telerik:RadToolBarButton>
                        </Items>
                    </telerik:RadToolBar>
                </CommandItemTemplate>
                <PagerStyle BackColor="#D8EBFC" Mode="NextPrevNumericAndAdvanced" />
                <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                <RowIndicatorColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>
                <ExpandCollapseColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>
                <GroupByExpressions>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="Views" FieldName="LayoutName" HeaderValueSeparator=" : "
                                FormatString="" HeaderText=""></telerik:GridGroupByField>
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="LayoutUserId" SortOrder="Ascending"></telerik:GridGroupByField>
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                </GroupByExpressions>
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderStyle-Width="10px">
                        <HeaderStyle Width="10px"></HeaderStyle>
                    </telerik:GridEditCommandColumn>
                    <telerik:GridNumericColumn DataField="LayoutId" HeaderText="LayoutId" SortExpression="LayoutId"
                        UniqueName="LayoutId" FilterControlWidth="20px" HeaderStyle-Width="80px" ReadOnly="true"
                        Visible="false">
                    </telerik:GridNumericColumn>
                    <telerik:GridHyperLinkColumn DataTextField="LayoutName" HeaderStyle-Width="150px"
                        DataNavigateUrlFields="LayoutId,LayoutName" HeaderText="LayoutName" SortExpression="LayoutName"
                        UniqueName="LayoutName" DataNavigateUrlFormatString="AssetsListBreakWork.aspx?LayoutId={0}&LayoutName={1}">
                    </telerik:GridHyperLinkColumn>
                    <telerik:GridNumericColumn DataField="LayoutUserId" HeaderText="LayoutUserId" SortExpression="LayoutUserId"
                        UniqueName="LayoutUserId" FilterControlWidth="20px" HeaderStyle-Width="80px"
                        Visible="false">
                    </telerik:GridNumericColumn>
                    <telerik:GridButtonColumn CommandName="Delete" ButtonType="ImageButton" HeaderStyle-Width="10px"
                        UniqueName="DeleteColumn" CommandArgument="Child" ConfirmDialogType="RadWindow"
                        ConfirmText="Are You Sure Want To Delete This Record?" ConfirmTitle="Delete Confirm">
                        <HeaderStyle Width="10px"></HeaderStyle>
                    </telerik:GridButtonColumn>
                </Columns>
                <EditFormSettings CaptionFormatString="Create" EditFormType="Template">
                    <EditColumn UniqueName="EditCommandColumn1">
                    </EditColumn>
                    <FormTemplate>
                        <div style="margin-left: 10px;">
                            <table>
                                <tr>
                                    <td style="height: 100px; width: 470px;">
                                        <table style="float: right;">
                                            <tr>
                                                <td>
                                                    <asp:Label ID="Label3" runat="server" ForeColor="Red" Text="*" Width="1px"></asp:Label>
                                                    <asp:Label ID="Label2" Text="Mandatory Field(s)" runat="server"></asp:Label>
                                                </td>
                                            </tr>
                                        </table>
                                        <fieldset>
                                            <legend style="margin-bottom: 10px">Layout</legend>
                                            <table cellspacing="2" cellpadding="1" width="470px" border="0">
                                                <tr>
                                                    <td colspan="2">
                                                        <asp:TextBox Width="200px" ID="LayoutId" AutoCompleteType="Disabled" runat="server"
                                                            Text='<%# Bind("LayoutId") %>' Visible="false"></asp:TextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right">
                                                        Layout Name :
                                                    </td>
                                                    <td>
                                                        <asp:TextBox Width="200px" ID="LayoutName" AutoCompleteType="Disabled" runat="server"
                                                            Text='<%# Bind("LayoutName") %>'></asp:TextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                        <fieldset>
                                                            <legend>Layout List</legend>
                                                            <table style="width: 450px;">
                                                                <tr>
                                                                   
                                                                    <td>
                                                                        <asp:Label ID="Label15" runat="server">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selected</asp:Label>
                                                                        <telerik:RadListBox runat="server" DataTextField="Text" DataValueField="Value" ID="RadListBoxDestinationGroup"
                                                                            AutoPostBackOnReorder="true" EnableDragAndDrop="true" AllowReorder="true" Height="140px"
                                                                            Width="160px" ButtonSettings-Position="Left">
                                                                        </telerik:RadListBox>
                                                                    </td>
                                                                    <td>
                                                                        <asp:Label ID="GroupAvailable" runat="server">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Available</asp:Label>
                                                                        <telerik:RadListBox Height="140px" Width="160px" runat="server" DataSourceID="SqlDataSource1"
                                                                            DataValueField="COLUMN_NAME" DataTextField="COLUMN_NAME" ID="RadListBoxSourceGroup"
                                                                            AllowTransfer="true" TransferToID="RadListBoxDestinationGroup" SelectionMode="Multiple"
                                                                            AllowReorder="false" AllowDelete="false" TransferMode="Move" AutoPostBackOnTransfer="true"
                                                                            AutoPostBackOnReorder="true" EnableDragAndDrop="true" ButtonSettings-Position="Left"
                                                                            OnTransferred="RadListBoxSourceGroup_Transferred">
                                                                        </telerik:RadListBox>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </fieldset>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td valign="top" align="right">
                                                        Layout UserId :
                                                    </td>
                                                    <td>
                                                        <asp:CheckBox ID="LayoutUserId" runat="server" Checked='<%# 2.Equals(Eval("LayoutUserId")) ? true : false %>' />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td valign="top" align="right">
                                                        Sort Column :
                                                    </td>
                                                    <td>
                                                        <telerik:RadComboBox ID="ComboBox_SortColumn" runat="server" Width="175px" SelectedValue='<%# Bind("SortColumn") %>'
                                                            AllowCustomText="true">
                                                            <Items>
                                                                <telerik:RadComboBoxItem Text="" />
                                                            </Items>
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td valign="top" align="right">
                                                        Sort Order :
                                                    </td>
                                                    <td>
                                                        <telerik:RadComboBox ID="ComboBox_SortOrder" runat="server" Width="175px" SelectedValue='<%# Bind("SortOrder") %>'>
                                                            <Items>
                                                                <telerik:RadComboBoxItem Text="Ascending" Value="Asc" Selected="true" />
                                                                <telerik:RadComboBoxItem Text="Descending" Value="Desc" />
                                                            </Items>
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td valign="top" align="right">
                                                        Group Column :
                                                    </td>
                                                    <td>
                                                        <telerik:RadComboBox ID="ComboBox_GroupByColumn" runat="server" Width="175px" DataSourceID="SqlDataSource1"
                                                            SelectedValue='<%# Bind("GroupColumn") %>' DataValueField="COLUMN_NAME" DataTextField="COLUMN_NAME">
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                            </table>
                                        </fieldset>
                                    </td>
                                </tr>
                            </table>
                            <table>
                                <tr>
                                    <td>
                                        <asp:Button ID="Button3" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                            CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                        </asp:Button>
                                        <asp:Button ID="Button4" runat="server" Text="Cancel" CausesValidation="false" CommandName="Cancel">
                                        </asp:Button>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </FormTemplate>
                    <PopUpSettings Modal="True"></PopUpSettings>
                </EditFormSettings>
            </MasterTableView>
            <ClientSettings>
                <Selecting AllowRowSelect="true" />
            </ClientSettings>
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
            SelectCommand="SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE (TABLE_NAME = 'Assets') ORDER BY ORDINAL_POSITION">
        </asp:SqlDataSource>
    </div>
    </form>
</body>
</html>


Thanks,
Mohamed.
0
mohamed
Top achievements
Rank 1
answered on 03 Jun 2011, 11:55 AM
Thanks Princy,

I got the and how to assign that value in radcombobox
please as soon as possible

Thanks ,
Mohamed.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Jun 2011, 11:58 AM
Hi,


protected void RadListBoxSourceGroup_Transferred(object sender, Telerik.Web.UI.RadListBoxTransferredEventArgs e)
        {
            RadListBox  RadListBoxSourceGroup = (RadListBox)RadListBoxSourceGroup;
            GridEditFormItem editItem = (GridEditFormItem)RadListBoxSourceGroup.NamingContainer;
             
            RadListBox  RadListBoxDestinationGroup = (RadListBox)editItem.FindControl("RadListBoxDestinationGroup");
                 RadComboBox RadComboBox1= (RadComboBox)editItem.FindControl("RadComboBox1");
                   //set value of check box
        }



Thanks,
Jayesh Goyani
0
mohamed
Top achievements
Rank 1
answered on 03 Jun 2011, 12:03 PM
Thanks For UR Reply


 protected void RadListBoxSourceGroup_Transferring(object sender, Telerik.Web.UI.RadListBoxTransferringEventArgs e)
        {
            RadListBox listbox = sender as RadListBox;
        }

That listbox value how to assign in that radcombobox
Reply As soon As possible

Thanks,
Mohamed.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Jun 2011, 12:15 PM
Hi

protected void RadListBoxSourceGroup_Transferred(object sender, Telerik.Web.UI.RadListBoxTransferredEventArgs e)
        {
            RadListBox  RadListBoxSourceGroup = (RadListBox)RadListBoxSourceGroup;
            GridEditFormItem editItem = (GridEditFormItem)RadListBoxSourceGroup.NamingContainer;
              
            RadComboBox RadComboBox1= (RadComboBox)editItem.FindControl("RadComboBox1");
                
            DataTable dt = new DataTable();
             dt.Columns.Add("ID", typeof(int));
            dt.Columns.Add("Name", typeof(string));
 
            foreach (RadListBoxItem item in RadListBoxSourceGroup.Items)
            {
                dt.Rows.Add(item.value,item.text);
            }
             
            RadComboBox1.DataSource = dt;
            RadComboBox1.DataTextField = "Name";
            RadComboBox1.DataValueField = "ID";
            RadComboBox1.DataBind();              
        }

if u want to add only seleted items then useRadListBoxSourceGroup.selecteditems

Thanks,
Jayesh Goyani
0
mohamed
Top achievements
Rank 1
answered on 03 Jun 2011, 12:20 PM
Thanks For Replay Jayesh Goyani

DataBind Error
That message like that

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
replay as soon as possible


Thanks,
Mohamed.
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Jun 2011, 12:38 PM
Hi,

sorry it was my mistake ..correct code shown in below..


Thanks,
Jayesh Goyani
protected void RadListBoxSourceGroup_Transferred(object sender, Telerik.Web.UI.RadListBoxTransferredEventArgs e)
        {
            RadListBox  RadListBoxSourceGroup = (RadListBox)sender;
            GridEditFormItem editItem = (GridEditFormItem)RadListBoxSourceGroup.NamingContainer;
               
            RadComboBox RadComboBox1= (RadComboBox)editItem.FindControl("RadComboBox1");
                 
            DataTable dt = new DataTable();
             dt.Columns.Add("ID", typeof(int));
            dt.Columns.Add("Name", typeof(string));
  
            foreach (RadListBoxItem item in RadListBoxSourceGroup.Items)
            {
                dt.Rows.Add(item.value,item.text);
            }
              
            RadComboBox1.DataSource = dt;
            RadComboBox1.DataTextField = "Name";
            RadComboBox1.DataValueField = "ID";
            RadComboBox1.DataBind();             
        }
0
mohamed
Top achievements
Rank 1
answered on 03 Jun 2011, 12:39 PM
Hello Jayesh Goyani .,

Thanks for ur help thought for this process .
Thanks Alot
worked code as i expected ....

protected void RadListBoxSourceGroup_Transferred(object sender, RadListBoxTransferredEventArgs e)
        {
            RadListBox RadListBoxSourceGroup = sender as RadListBox;
            GridEditFormItem editItem = (GridEditFormItem)RadListBoxSourceGroup.NamingContainer;

            RadListBox soucre = (RadListBox)editItem.FindControl("RadListBoxDestinationGroup");
            RadComboBox sortcolumn = (RadComboBox)editItem.FindControl("ComboBox_SortColumn");
            RadComboBox groupcolumn = (RadComboBox)editItem.FindControl("ComboBox_GroupByColumn");

            DataTable dt = new DataTable();
            dt.Columns.Add("ID", typeof(string));
            dt.Columns.Add("Name", typeof(string));

            foreach (RadListBoxItem item in soucre.Items)
            {
                dt.Rows.Add(item.Value, item.Text);
            }

            sortcolumn.DataSource = dt;
            sortcolumn.DataValueField = "ID";
            sortcolumn.DataTextField = "Name";
            sortcolumn.DataBind();

            groupcolumn.DataSource = dt;
            groupcolumn.DataValueField = "ID";
            groupcolumn.DataTextField = "Name";
            groupcolumn.DataBind();
        }




Thanks,
Mohamed.
Tags
Grid
Asked by
mohamed
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Princy
Top achievements
Rank 2
mohamed
Top achievements
Rank 1
Share this question
or