Hello,
I have a radgrid with a detailedtable in it. Also I have a Custom FormTemplate.
When I press the 'add new record' button, I would like the form to fill with the apropriate info and have the dropdownlists on the value that was saved in the database. For some reason I can not use 'selectedvalue = <% ... %>' I get the error that it can not be set declarativily.
So I added a onItemCommand function (see below). This works fine for the dropdownlists, but now the textboxex in the custom form are empty. Is there any other way to select an item in the dropdownlists, or is it possible to get the values for the textboxex from the OwnerTableView or something?
I hope someone can help me, couse it drives me insane!!
protected void grdAccounts_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) {
if (e.CommandName == RadGrid.EditCommandName) {
string sAccountType = grdAccounts.MasterTableView.DataKeyValues[e.Item.ItemIndex]["AccountType"].ToString();
e.Canceled = true;
e.Item.OwnerTableView.InsertItem();
GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem();
((DropDownList)(insertedItem.FindControl("drpAccountType"))).SelectedValue = sAccountType;
}
}
I have a radgrid with a detailedtable in it. Also I have a Custom FormTemplate.
When I press the 'add new record' button, I would like the form to fill with the apropriate info and have the dropdownlists on the value that was saved in the database. For some reason I can not use 'selectedvalue = <% ... %>' I get the error that it can not be set declarativily.
So I added a onItemCommand function (see below). This works fine for the dropdownlists, but now the textboxex in the custom form are empty. Is there any other way to select an item in the dropdownlists, or is it possible to get the values for the textboxex from the OwnerTableView or something?
I hope someone can help me, couse it drives me insane!!
protected void grdAccounts_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) {
if (e.CommandName == RadGrid.EditCommandName) {
string sAccountType = grdAccounts.MasterTableView.DataKeyValues[e.Item.ItemIndex]["AccountType"].ToString();
e.Canceled = true;
e.Item.OwnerTableView.InsertItem();
GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem();
((DropDownList)(insertedItem.FindControl("drpAccountType"))).SelectedValue = sAccountType;
}
}