or

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="True" ShowHeader="false" BorderWidth="1px" Skin="Office2007" Width="495" Height="100%" OnNeedDataSource="RadGrid1_NeedDataSource" OnDeleteCommand="RadGrid1_DeleteCommand" OnInsertCommand="RadGrid1_InsertCommand" OnUpdateCommand="RadGrid1_UpdateCommand"> <MasterTableView DataKeyNames="NV_ID" CommandItemDisplay="Top" EditMode="PopUp" Font-Names="Arial" ForeColor="Black"> <CommandItemSettings AddNewRecordText="Thêm mới" ShowRefreshButton="false" /> <NoRecordsTemplate> No record</NoRecordsTemplate> <RowIndicatorColumn> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <EditFormSettings CaptionFormatString="Edit NV_ID: {0}" CaptionDataField="NV_ID" > <PopUpSettings /> </EditFormSettings> <Columns> <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"> </telerik:GridEditCommandColumn> <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton"> </telerik:GridButtonColumn> </Columns> </MasterTableView> </telerik:RadGrid>protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e) { var editableItem = ((GridEditableItem)e.Item); //create new entity var item_nv = new DM_NHAN_VIEN(); //item_nv.Ma_DonVi = "CNTT"; item_nv.NV_ID = 99999; item_nv.Ten_DD = "test insert"; item_nv.Ten_TCap = "T_Insert"; item_nv.Mat_Khau = ""; DbContext.DM_NHAN_VIENs.InsertOnSubmit(item_nv); try { //submit chanages to Db DbContext.SubmitChanges(); } catch (Exception ex) { //ShowErrorMessage(); lblmes.Text = ex.Message; } }
<telerik:GridButtonColumn ConfirmText="Remove this GCS Security Function?" ConfirmDialogType="RadWindow" ConfirmTitle="Remove" CommandName="Delete" Text="Remove this GCS Security Function" UniqueName="DeleteColumn" ButtonType="ImageButton"></telerik:GridButtonColumn>protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e){ if (e.CommandName == RadGrid.ExportToPdfCommandName) { RadGrid1.MasterTableView.DetailTables[0].GetColumn("DeleteColumn").Visible = false; return; }}
