i am having the worst time trying to set the value of a column of a radgrid when the user clicks the "Add New Item" link.
the setup is a RadGrid control bound to an EntityDataSource whose underlying table has two primary keys, one of which is foreign ( much like a parent child scenario). that key is ItemID.
The real problem is that though RadGrid knows the keys - it will not use them in the insert, thereby generating a foreign key constraint error. so i get to find some way to populate the grid column ItemID with the foreign key value ItemID.
the event handler is:
the column of interest is:
unfortunately when the editor is displayed (after the user clicks the Add New Item link), the ItemID value is blank causing the insert into the table to fail when the user clicks insert. i am using default Add New functionality - whatever that is called.
what am i doing wrong?
the setup is a RadGrid control bound to an EntityDataSource whose underlying table has two primary keys, one of which is foreign ( much like a parent child scenario). that key is ItemID.
The real problem is that though RadGrid knows the keys - it will not use them in the insert, thereby generating a foreign key constraint error. so i get to find some way to populate the grid column ItemID with the foreign key value ItemID.
the event handler is:
protected
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
GridEditableItem editedItem = e.Item
as
GridEditableItem;
if
(editedItem !=
null
)
{
editedItem[
"ItemID"
].Text = editedItem.GetDataKeyValue(
"ItemID"
).ToString();
}
}
the column of interest is:
<
telerik:GridBoundColumn
DataField
=
"ItemID"
FilterControlAltText
=
"Filter column column"
HeaderText
=
"Item ID"
UniqueName
=
"ItemID"
DefaultInsertValue='<%# I wish i could reference the Key Values%>' >
</
telerik:GridBoundColumn
>
unfortunately when the editor is displayed (after the user clicks the Add New Item link), the ItemID value is blank causing the insert into the table to fail when the user clicks insert. i am using default Add New functionality - whatever that is called.
what am i doing wrong?