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

how bind in radlistbox in <GridEditCommandColumn>

2 Answers 118 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mohamed
Top achievements
Rank 1
mohamed asked on 06 Jun 2011, 12:04 PM
Hello Every One,

I'm using GridEditCommandColumn  for modify
how bind radlistbox in the GridEditCommandColumn  modify mode

i'm using assigned value for this EditFormSettings ...
Reply As soon as possible

<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 width="50%">
                                                                        <asp:Label ID="Label15" runat="server">         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 width="50%">
                                                                        <asp:Label ID="GroupAvailable" runat="server">         Available</asp:Label>
                                                                        <telerik:RadListBox 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"
                                                                            Height="140px" Width="160px" 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" DataValueField="ID"
                                                            DataTextField="Name">
                                                        </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" DataValueField="ID"
                                                            DataTextField="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>


Thanks,
Mohamed

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 06 Jun 2011, 01:49 PM
Hello Mohammed,

I am not quite sure about your requirement. I suppose you want to access the RadListBox in EditFormSettings and then populate. If that is the requirement, try the following code. Hope this helps.

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
 {
  GridEditFormItem item = (GridEditFormItem)e.Item;
  RadListBox listbox = (RadListBox)item.FindControl("RadListBoxDestinationGroup");
   listbox.DataSource=//set your data source
}
}

Thanks,
Shinu.
0
mohamed
Top achievements
Rank 1
answered on 06 Jun 2011, 02:43 PM
Hello Shinu,

Thanks For Ur reply Shinu,

i get assign the all the records  with the help ur posted code ,

if i go add new mode button click ,
list box fields are assigned and come like that modify,
   protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
            {
                GridEditFormItem item = (GridEditFormItem)e.Item;
                Int32 LayoutId = Convert.ToInt32(item["LayoutId"].Text);
                RadListBox listbox = (RadListBox)item.FindControl("RadListBoxDestinationGroup");
 
              listbox.DataSource = DbClient.GetList<ListField>("LayoutId =" + LayoutId);
                listbox.DataValueField = "ListFieldId";
                listbox.DataTextField = "FieldName";
}

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