I'm trying to use the Automatic Update/Insert/Delete to save a lot of time, however I'm stuck with a grid that will not populate the DropDownList. When I go into edit mode, the dropdown displays a blank list but the ddList is populated in the c# code. What am I doing wrong?
This is the code behind on the ItemDataBound
Regards
Steve
<MasterTableView EditMode="PopUp" CommandItemDisplay="Top" DataKeyNames="Make,Model"> |
<Columns> |
<telerik:GridDropDownColumn ColumnEditorID="Make" |
DataField="Make" |
DataType="System.String" |
Display="true" |
DropDownControlType="RadComboBox" |
HeaderText="Make" |
ReadOnly="false" |
SortExpression="Make" |
UniqueName="Make"> |
</telerik:GridDropDownColumn> |
</Columns> |
<EditFormSettings CaptionFormatString="Edit " |
PopUpSettings-Modal="true" /> |
</MasterTableView> |
This is the code behind on the ItemDataBound
if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) |
{ |
GridEditableItem eeditedItem = e.Item as GridEditableItem; |
GridEditManager editMan = editedItem.EditManager; |
GridDropDownListColumnEditor editor = editMan.GetColumnEditor("Make") as GridDropDownListColumnEditor; |
DataTable data = new DataTable(); |
SqlConnection conn = null; |
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Demo Database NAV (6-0)ConnectionString"].ConnectionString); |
conn.Open(); |
SqlCommand cmd = new SqlCommand("Makes", conn); |
cmd.CommandType = CommandType.StoredProcedure; |
cmd.Parameters.Add(new SqlParameter("@strCriteriaMake", Convert.ToString(editor.SelectedValue).ToUpper())); |
using (SqlDataAdapter da = new SqlDataAdapter(cmd)) |
{ |
da.Fill(data); |
} |
DropDownList ddList = editor.DropDownListControl; |
for (int i = 0; i < data.Rows.Count; i++) |
{ |
ddList.Items.Add(data.Rows[i]["Make"].ToString()); |
} |
ddList.DataBind(); |
} |
Regards
Steve