I am using a RadGrid and I want to insert a new item into the grid using the built-in RadGrid functionality. The new item has been defined as follows:
<EditFormSettings EditFormType="Template">
<FormTemplate>
<div>
<h3>
New Team Culture Assessment
</h3>
<table>
<tr>
<td>
<asp:Label ID="EntitiesLabel" runat="server" Text="Entities"></asp:Label>
</td>
<td>
<asp:DropDownList ID="EntityList" runat="server" AutoPostBack="True"
OnSelectedIndexChanged = "Entity_selected"></asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="TeamsLabel" runat="server" Text="Teams"></asp:Label>
</td>
<td>
<asp:DropDownList ID="TeamList" runat="server">
</asp:DropDownList>
</td>
</tr>
</table>
</div>
</FormTemplate>
</EditFormSettings
>
My questions:
1. I want to populate the EntityList and TeamList drop-downs in the page-load using "object data source", but when I access them directly, I am getting an error saying that the name EntityList is not found in current context...here is what I am doing in !postback in page_load:
var bd = new BfEntityDAO();
List<BfEntity> ents = bd.GetEntities();
EntityList.DataSource = ents;
EntityList.DataTextField = "BfEntityName";
EntityList.DataBind();
How can I populate these drop-downs so that the user can see the values when he inserts a new item?
2. When the user opens the insert form and selects an entity from the entitylist drop-down, I want to populate the teamlist drop-down based on the value selected in the entitylist drop-down. How can I accomplish this?
This is the code snippet I am using currently in the codebehind, but the method is not being called:
{
var cd = new TeamDAO();
List<Team> teams = cd.GetTeamsForEntity(entityDropDown.SelectedValue);
teamDropDown.DataSource = teams;
teamDropDown.DataTextField = "TeamName";
teamDropDown.DataValueField = "Id";
teamDropDown.DataBind();
}
catch (Exception ex)
{
Common.Utils.HandleException(ex);
}
3. Finally, when the user clicks OK on the form, I want a insert the data into the database from the code-behind file. How can I get a callback to method in the code-behind and how can I access the data entered by the user?
Thank you