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

Dynamic RadGrid, Edit Button clears screen

1 Answer 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 08 Jan 2013, 09:38 PM
I've created a Dynamic RadGrid on a Web User Control (ascx), and it displays correctly. However when I click on the Edit button the grid simply disappears. In order to determine what is going on I've tried to connect the OnItemCommand Event, but it does not fire? Listed below is a scaled version of the Dynamic Grid Creation, which is being executed by the PageInit Method.

My goal is to have the Edit Popup Modal show up when the User Clicks Edit, and be able to then catch the Update Click in order to manage the update back to the Data Source.

 

protected void BuildGrid(DataRow curRow)
{
    var curGrid = new RadGrid
          {
              ID = curRow.Field<string>("tst_desc"),
              Skin = "Hay",
              GridLines = GridLines.Both,
              AutoGenerateColumns = false,
              AllowAutomaticUpdates = true
          };
    curGrid.MasterTableView.Name = curRow.Field<string>("tst_desc");
    curGrid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Bottom;
    curGrid.MasterTableView.TableLayout = GridTableLayout.Fixed;
    curGrid.MasterTableView.EditMode = GridEditMode.PopUp;
    curGrid.MasterTableView.EditFormSettings.EditFormType = GridEditFormType.AutoGenerated;
    curGrid.MasterTableView.CommandItemSettings.ShowRefreshButton = false;
    curGrid.MasterTableView.CommandItemSettings.AddNewRecordText = "Add More " + curRow.Field<string>("tst_desc") + " Test Results";
    curGrid.NeedDataSource += new GridNeedDataSourceEventHandler(Grid_OnNeedDataSource);
    curGrid.ItemCommand += new GridCommandEventHandler(Grid_OnItemCommand);
    curGrid.ClientSettings.AllowKeyboardNavigation = true;
    var btnCol = new GridButtonColumn
         {
             ButtonType = GridButtonColumnType.ImageButton,
             HeaderText = "Edit",
             CommandArgument = "btnEdit",
             UniqueName = "btnEdit",
             CommandName = "Edit"
         };
    curGrid.MasterTableView.Columns.Add(btnCol);
    var gbcUpdBy = new GridBoundColumn
       {
           UniqueName = "UPDT_BY",
           HeaderText = "Last Updated By",
           DataField = "updt_by",
           ReadOnly = true
       };
    curGrid.MasterTableView.Columns.Add(gbcUpdBy);
    var gbcUpdDt = new GridBoundColumn
       {
           UniqueName = "UPDT_DT",
           HeaderText = "Last Updated",
           DataField = "updt_dt",
           DataFormatString = "{0:MM/dd/yy}",
           ReadOnly = true
       };
    curGrid.MasterTableView.Columns.Add(gbcUpdDt);
    PlaceHolder1.Controls.Add(curGrid);
    Session[curRow.Field<string>("tst_desc") + "ID"] = curRow.Field<int>("lab_tst_id").ToString(CultureInfo.InvariantCulture);
    PlaceHolder1.Controls.Add(new LiteralControl("<br />"));
    PlaceHolder1.Controls.Add(new LiteralControl("<br />"));
}
 
void Grid_OnItemCommand(object sender, GridCommandEventArgs e)
{
    var a = 123;
}
 
void Grid_OnNeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    var curGrid = sender as RadGrid;
    var gridName = curGrid.MasterTableView.Name;
    var hidTestId = Session[gridName + "ID"];
    curGrid.DataSource = ExecSQL.SQLData(_sqlStmt + " AND lt.lab_tst_id = " + hidTestId);
 
}

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 11 Jan 2013, 01:58 PM
Hello,

I answered your query in the support ticket you have opened. I suggest to continue the discussion there.

All the best,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or