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

Dynamic Values for RadCombo within EditFormSettings

1 Answer 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Atlas
Top achievements
Rank 1
Atlas asked on 07 Jul 2010, 01:00 AM
I have the following template:
                                <EditFormSettings EditFormType="Template">  
                                    <FormTemplate> 
                                        <table id="Table1" cellspacing="1" cellpadding="1" width="400px" border="0">  
                                            <tr> 
                                                <td align="right">  
                                                    Company Name:  
                                                </td> 
                                                <td align="left">  
                                                    <telerik:RadComboBox ID="rcbCompany" runat="server" AppendDataBoundItems="true" 
                                                        DataTextField="CompanyName" DataValueField="CompanyId">  
                                                        <Items> 
                                                            <telerik:RadComboBoxItem Text="Select a Company" Value="" /> 
                                                        </Items> 
                                                    </telerik:RadComboBox> 
                                                </td> 
                                            </tr> 
                                            <tr> 
                                                <td align="right">  
                                                    Role Name:  
                                                </td> 
                                                <td align="left">  
                                                    <telerik:RadComboBox ID="rcbRole" runat="server" DataTextField="RoleName" DataValueField="ApRoleId" 
                                                        Enabled="false">  
                                                        <Items> 
                                                            <telerik:RadComboBoxItem Text="Select a Role" Value="" /> 
                                                        </Items> 
                                                    </telerik:RadComboBox> 
                                                </td> 
                                            </tr> 
                                            <tr> 
                                                <td align="right" colspan="2">  
                                                    <asp:Button ID="Button1" Text="Insert" runat="server" CommandName="PerformInsert" />&nbsp;  
                                                    <asp:Button ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" /> 
                                                </td> 
                                            </tr> 
                                        </table> 
                                    </FormTemplate> 
                                </EditFormSettings> 
 
And I would like to bind the data of the RadComboBoxes in the CodeBehind on the fly.
Which event do I tie into to accomplish this?

I have two events:

    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)  
    {  
        if (e.CommandName == "InsertChild")  
        {  
            GridDataItem item = (GridDataItem)e.Item;  
            Guid _sysUserId = (Guid)item.GetDataKeyValue("SysUserId");  
            GridTableView tableView = (GridTableView)item.ChildItem.NestedTableViews[0];  
            tableView.IsItemInserted = true;  
            tableView.Rebind();  
        }    
 
 
and
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridEditFormInsertItem)  
        {  
            GridEditFormInsertItem item = (GridEditFormInsertItem)e.Item;  
 
            RadComboBox rcbCompany = (RadComboBox)item.FindControl("rcbCompany");  
 
            if (rcbCompany != null)  
            {  
                Database db = DatabaseFactory.CreateDatabase();  
                string sqlCommand = "uspGetUserCompaniesAvailable";  
 
                DbCommand dbdbCommand = db.GetStoredProcCommand(sqlCommand);  
 
                db.AddInParameter(dbCommand, "@SYSUSER_ID", DbType.Guid, new Guid(""));  
 
                DataSet ds = db.ExecuteDataSet(dbCommand);  
                rcbCompany.DataSource = ds;  
                //rcbCompany.DataBind();  
            }  
        }  
    }  
 
neither of which will allow me to accomplish my goal. If I attempt to use FindControl in the item command, the control is always null,
If I use it in the databound method, I get an error on DataBind().

What event would I use to bind data to the RadComboBox's

1 Answer, 1 is accepted

Sort by
0
Atlas
Top achievements
Rank 1
answered on 07 Jul 2010, 01:27 AM
My bad,
the problem was that I was using SelectedValue= with Bind. which does not work on insert.
Tags
Grid
Asked by
Atlas
Top achievements
Rank 1
Answers by
Atlas
Top achievements
Rank 1
Share this question
or