I have the following template:
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:
and
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
<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" /> |
<asp:Button ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" /> |
</td> |
</tr> |
</table> |
</FormTemplate> |
</EditFormSettings> |
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(); |
} |
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(); |
} |
} |
} |
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