我是Telerik的新手并尝试使用RadGrid:
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True"
AllowAutomaticInserts="True" PageSize="10" OnItemDeleted="RadGrid1_ItemDeleted" OnInsertCommand="RadGrid1_ItemInserted"
OnItemUpdated="RadGrid1_ItemUpdated" OnPreRender="RadGrid1_PreRender" AllowAutomaticUpdates="True" AllowPaging="True"
AutoGenerateColumns="False" OnBatchEditCommand="RadGrid1_BatchEditCommand" DataSourceID="SqlDataSource1">
<MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="PRODUCTID"
DataSourceID="SqlDataSource1" HorizontalAlign="NotSet" EditMode="Batch" AutoGenerateColumns="False">
<BatchEditingSettings EditType="Cell" />
<SortExpressions>
<telerik:GridSortExpression FieldName="PRODUCTID" SortOrder="Ascending" />
</SortExpressions>
<Columns>
<telerik:GridBoundColumn DataField="PRODUCTID" HeaderStyle-Width="210px" HeaderText="PRODUCTID" SortExpression="PRODUCTID"
UniqueName="PRODUCTID" DataType="System.Decimal" FilterControlAltText="Filter PRODUCTID column" ReadOnly="True">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="PRODUCTNAME" DataType="System.String" FilterControlAltText="Filter PRODUCTNAME column" HeaderText="PRODUCTNAME" SortExpression="PRODUCTNAME" UniqueName="PRODUCTNAME">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="DESCRIPTION" FilterControlAltText="Filter DESCRIPTION column" HeaderText="DESCRIPTION" SortExpression="DESCRIPTION" UniqueName="DESCRIPTION">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="COLOR" FilterControlAltText="Filter COLOR column" HeaderText="COLOR" SortExpression="COLOR" UniqueName="COLOR">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="UOM" FilterControlAltText="Filter UOM column" HeaderText="UOM" SortExpression="UOM" UniqueName="UOM">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="STATUS" FilterControlAltText="Filter STATUS column" HeaderText="STATUS" SortExpression="STATUS" UniqueName="STATUS">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CREATEDBY" FilterControlAltText="Filter CREATEDBY column" HeaderText="CREATEDBY" SortExpression="CREATEDBY" UniqueName="CREATEDBY">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LASTUPDATEDBY" FilterControlAltText="Filter LASTUPDATEDBY column" HeaderText="LASTUPDATEDBY" SortExpression="LASTUPDATEDBY" UniqueName="LASTUPDATEDBY">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton"
CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
</telerik:GridButtonColumn>
</Columns>
</MasterTableView>
<ClientSettings AllowKeyboardNavigation="true"></ClientSettings>
</telerik:RadGrid>
那么,当我单击CodeBehind文件(RadGrid1_ItemInserted函数)中的Save按钮来使用存储过程时,如何获取插入项的值。我跟着here修改了那段代码(不想使用SQLDatasource) 请求帮助!
答案 0 :(得分:0)
禁用自动CRUD操作并使用BatchEditCommand事件:http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing
IT展示了如何遍历命令以查看编辑/添加/删除的内容,显示如何在哈希表中获取值,然后您可以编写SQL查询或其他将修改数据库的逻辑。