<
telerik:RadGrid runat="server" ID="RadGrid2" AllowPaging="True"
AllowSorting="True" Width="97%" DataSourceID="EntityDataSource1" AllowAutomaticInserts="True"
AllowAutomaticUpdates="True" AllowAutomaticDeletes="False" ShowStatusBar="True"
GridLines="None" AutoGenerateEditColumn="True"
AutoGenerateColumns="False" OnItemCommand="RadGrid2_ItemCommand">
<PagerStyle Mode="NumericPages" AlwaysVisible="true" />
<MasterTableView Width="100%" CommandItemDisplay="Top"
DataSourceID="EntityDataSource1"
DataKeyNames="VendorCrewId">
<Columns>
<telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName"
SortExpression="FirstName" UniqueName="FirstName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LastName" HeaderText="LastName" SortExpression="LastName"
UniqueName="LastName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Bio" HeaderText="Bio"
SortExpression="Bio" UniqueName="Bio" ItemStyle-Width="300px" ItemStyle-HorizontalAlign="NotSet">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn DataField="IsActive" DataType="System.Boolean"
HeaderText="IsActive" SortExpression="IsActive" UniqueName="IsActive">
</telerik:GridCheckBoxColumn>
<telerik:GridBinaryImageColumn DataField="Image" HeaderText="Image" UniqueName="Upload" ImageAlign="NotSet"
ImageHeight="80px" ImageWidth="80px" ResizeMode="Fit"
DataAlternateTextFormatString="Image of {0}">
<HeaderStyle Width="10%" />
</telerik:GridBinaryImageColumn>
<telerik:GridBoundColumn DataField="VendorCrewId" DataType="System.Int32"
HeaderText="VendorCrewId" ReadOnly="True" Visible="False" SortExpression="VendorCrewId"
UniqueName="VendorCrewId">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CompanyEntities.CompanyEntityId"
DataType="System.Int32" HeaderText="Vendor Id"
SortExpression="CompanyEntities.CompanyEntityId"
Visible="False">
</telerik:GridBoundColumn>
</Columns>
<EditFormSettings EditFormType="AutoGenerated">
<EditColumn ButtonType="ImageButton" />
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
protected void RadGrid2_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked
{
e.Canceled =
true;
//Prepare an IDictionary with the predefined values
System.Collections.Specialized.
ListDictionary newValues = new System.Collections.Specialized.ListDictionary();
newValues[
"CompanyEntities.CompanyEntityId"] = Page.Request.QueryString["1"];
newValues[
"IsActive"] = true;
//Insert the item and rebind
e.Item.OwnerTableView.InsertItem(newValues);
}
}