Hi All,
I need to use showInsertItem property that switches the grid in insert mode and displays the insertion form when i click "Add New Record" on RadGrid.
I Created RadGrid Programmatically and assigned grid.ClientSettings.ClientEvents.OnCommand = "addnewrecord";
Then i register RegisterClientScriptBlock for addnewrecord on Page_Prerender.
This is my code:
RadGrid grid;
protected void Page_Load(object sender, EventArgs e)
{
DataTable gridDataTable = new DataTable();
grid = new RadGrid();
grid.ID = "grid1";
grid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
grid.MasterTableView.AllowAutomaticInserts = true;
grid.MasterTableView.InsertItemDisplay = GridInsertItemDisplay.Bottom;
GridBoundColumn col1 = new GridBoundColumn();
col1.HeaderText = "col1";
col1.DataField = "col1";
GridBoundColumn col2 = new GridBoundColumn();
col2.HeaderText = "col2";
col2.DataField = "col2";
grid.Columns.Add(col1);
grid.Columns.Add(col2);
grid.ClientSettings.ClientEvents.OnCommand = "addnewrecord";
grid.DataSource = gridDataTable;
grid.DataBind();
Page.Form.Controls.Add(grid);
}
protected void Page_PreRender(object sender, EventArgs e)
{
string clientd = grid.ClientID;
string gridScript = "function addnewrecord(sender, args){var masterTable = $find('" + clientd + "').get_masterTableView();masterTable.showInsertItem();}";
ScriptManager.RegisterClientScriptBlock(this.Page, typeof(Page), "mykey", gridScript, true);
}
Now,When i click "Add New Record" i get this error:Out of stack space.
Any Help is really appreciated.
Regards,
Ahmad