All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:
<
telerik:GridDropDownColumn
HeaderText
=
"ShipCity"
UniqueName
DataField
ListTextField
ListValueField
DataSourceID
"SqlDataSource1"
>
</
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
//Populate in EditMode
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
GridEditableItem edititem = (GridEditableItem)e.Item;
GridEditManager editMan = edititem.EditManager;
GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)(editMan.GetColumnEditor(
));
RadComboBox rComboBox = editor.ComboBoxControl;
string
selectedVal = DataBinder.Eval(edititem.DataItem,
).ToString();
DataTable table = GetRelatedRecords(
"SELECT ShipCity FROM [Orders]"
);
editor.DataSource = table;
rComboBox.DataSource = table;
rComboBox.DataTextField =
;
rComboBox.DataValueField =
rComboBox.DataBind();
rComboBox.SelectedValue = selectedVal;
}
public
static
DataTable GetRelatedRecords(
query)
SqlConnection conn =
new
SqlConnection(ConnString);
SqlDataAdapter adapter =
SqlDataAdapter();
adapter.SelectCommand =
SqlCommand(query, conn);
DataTable myDataTable =
DataTable();
conn.Open();
try
adapter.Fill(myDataTable);
finally
conn.Close();
return
myDataTable;