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

[Solved] EditFormSettings FormTemplate RadComboBox DataSource definition

5 Answers 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dmitri
Top achievements
Rank 1
Dmitri asked on 19 Jan 2012, 03:06 AM
I have an edit form inside of a grid and i need to set the data source for the RadComboBox to be populated from a LINQ query that runs on page load. I cant figure out how to do this:

The LINQ statement used is: tudc.Users.Select(f => f.Team).Distinct().ToArray();

                        <EditFormSettings EditFormType="Template">
                        <FormTemplate>
                            <table id="ET" cellpadding="1" cellspacing="0" width="100%" border="0" rules="none" style="border-collapse: collapse; background: white;">
                                <tr class="EditFormHeader"><td colspan="2">User Details</td></tr>
                                <tr>
                                   <td class="FieldName">Last Name:</td><td><telerik:RadTextBox runat="server" Skin="Office2010Blue" ID="rtb_LastName" Text='<%# Bind("Name_Last") %>' /></td>
                                </tr><tr>
                                   <td class="FieldName">First Name:</td><td><telerik:RadTextBox runat="server" Skin="Office2010Blue" ID="rtb_FirstName" Text='<%# Bind("Name_First") %>' /></td>
                                </tr><tr>
                                   <td class="FieldName">Username:</td><td><telerik:RadTextBox runat="server" Skin="Office2010Blue" ID="rtb_Username" Text='<%# Bind("Username") %>' /></td>
                                </tr><tr>
                                   <td class="FieldName">Password:</td><td><telerik:RadTextBox runat="server" Skin="Office2010Blue" ID="rtb_Password" TextMode="Password" Text='<%# Bind("Username") %>' /></td
                                </tr><tr>
                                   <td class="FieldName">Type:</td><td><telerik:RadComboBox runat="server" Skin="Office2010Blue" ID="rcb_Type" SelectedValue='<%# Bind("Type") %>' DataSource='<%# (new string[] {"Team Lead", "EDA", "Hybrid", "Admin"}) %>' /></td>
                                </tr><tr>
                                   <td class="FieldName">Team:</td><td><telerik:RadComboBox runat="server" Skin="Office2010Blue" ID="rcb_Team" SelectedValue='<%# Bind("Team") %>' DataSource='<%#?!?!?!?! WHAT GOES HERE %>' /></td>
                                </tr>
                            </table>
                        </FormTemplate>
                        </EditFormSettings>

5 Answers, 1 is accepted

Sort by
0
Dmitri
Top achievements
Rank 1
answered on 19 Jan 2012, 06:03 PM
Nevermind i found the solution
0
Lak
Top achievements
Rank 1
answered on 20 Mar 2013, 05:17 PM
Hi Dmitri,
I am having the same problem. Could you please send some sample code?
Thanks.
0
Shinu
Top achievements
Rank 2
answered on 22 Mar 2013, 08:55 AM
Hi,

Please take a look into the following code snippet to populate the RadComboBox.

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem EditableItem = (GridEditableItem)e.Item;
        RadComboBox combo = (RadComboBox)EditableItem.FindControl("ComboBoxID");
        //you can bind the RadComboBox here..
    }
}

Please elaborate the scenario if it doesn't help.

Thanks,
Shinu.
0
Lak
Top achievements
Rank 1
answered on 27 Mar 2013, 03:11 AM
Thanks Shinu.
I have one more issue, i need to show/hide couple of html tr tags based on the value selected from RadComboBox in the SelectedIndexChanged event. How can i do that?
Below is my code and is not working. tRow1 is coming up as null. On the html side, i set the id and runat=server properties to all the tr tags. Please help!

GridEditableItem editedItem = (sender as RadComboBox).NamingContainer as GridEditableItem;

RadComboBox cbo1 = (sender as RadComboBox).Parent.FindControl("cbo1") as RadComboBox;
string strSelectedText = cbo1.Text.ToString().Trim().ToUpper();

TableRow tRow1 = editedItem.FindControl("trId1") as TableRow;

if (strSelectedText == "JOHN")
{
//hide html tr's
 tRow1.Visible = false;
}
else
 tRow1.Visible = true;

0
Shinu
Top achievements
Rank 2
answered on 27 Mar 2013, 05:18 AM
HI,

Try the following code.
C#:
protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
 {
        RadComboBox combo = (RadComboBox)sender;
        GridEditableItem item = (GridEditableItem)combo.NamingContainer;
        TableRow tr = (TableRow)item.FindControl("tr1");
}

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