This is a migrated thread and some comments may be shown as answers.

How to NOT show editform

3 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ing. Jesus Manuel
Top achievements
Rank 1
Ing. Jesus Manuel asked on 04 Jun 2013, 11:37 PM
Hi, I have a radGrid with the "Add New" button on top, what I want to do, is to not show the Edit Form when I click on this button, I just want to catch this event with OnItemCommand and do some things there, without showing the EditForm on the RadGrid

protected void dtgPilot_OnItemCommand(object sender, GridCommandEventArgs e)
        {
                switch (Convert.ToString(e.CommandName))
                {
                    case "InitInsert":
                        //Code here
                        break;
                }
 
            }
        }

radGrid: 
<telerik:RadGrid runat="server" id="dtgPilot" AllowPaging="true"   AutoGenerateColumns="false"
                        OnItemCommand="dtgPilot_OnItemCommand" >
                        <MasterTableView CommandItemDisplay="Top" DataKeyNames="Id" >
                            <CommandItemSettings AddNewRecordText="Add New" ShowRefreshButton="false" />
                            <Columns>
                                <telerik:GridNumericColumn DataField="Id" Visible="false" />
                                <telerik:GridBoundColumn   DataField="PilotName" HeaderText="Name" /><telerik:GridBoundColumn   DataField="LicenceNumber" HeaderText="License #" />
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>

thanks

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Jun 2013, 04:49 AM
Hi,

Please try the code in OnItemDataBound event,here you can access the editform when Add New record button is clicked.

C#:
protected void OnItemDataBound(object sender, GridItemEventArgs e)
{
 if (e.Item is GridEditableItem && e.Item.OwnerTableView.IsItemInserted)
  {
    e.Item.OwnerTableView.IsItemInserted = false;//set the edit form of insert invisible.
  }
}

Thanks
Princy
0
Ing. Jesus Manuel
Top achievements
Rank 1
answered on 10 Jun 2013, 04:34 PM
It didn't work bro, anyone else know how to do this? Thanks
0
Princy
Top achievements
Rank 2
answered on 11 Jun 2013, 06:12 AM
Hi,

I guess you want one event at a time,here is the code,as,when you hit edit the add new hides and vice versa.
Hope this helps you.

C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
   if (e.CommandName == RadGrid.EditCommandName)
  {    
    RadGrid1.MasterTableView.IsItemInserted = false;          
  }
   if (e.CommandName == RadGrid.InitInsertCommandName)
  {      
    RadGrid1.MasterTableView.ClearEditItems();          
  
}

Thanks
Princy
Tags
Grid
Asked by
Ing. Jesus Manuel
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ing. Jesus Manuel
Top achievements
Rank 1
Share this question
or