Free Support Forum - aspose.com

Bindcolumn + cellcommand at runtime

Hi Aspose Team,

I'm trying to add a cellCommand on the first column of my dataTable.
I proceed like :

//in OnInit
grid.CellCommand += new CellEventHandler(grid_CellCommand);
cells.Clear();
sheet.DataSource = data;
sheet.EnableCreateBindColumnHeader = true;
sheet.CreateAutoGenratedColumns();
sheet.DataBind();
sheet.BindColumns[0].CommandName = "Info";

//handler
void grid_CellCommand(object sender, CellEventArgs e)
{Response.Redirect(urlToInfo); }

but it doesn't work.
Is it the correct way to do it at runtime?

Hi,

Thanks for pointing it out.

We will check to sort it out.

Thank you.

Hi,

Command cells are generated in the DataBind routine, so you should set the command name for a column before calling the DataBind method.

Please move this line:

sheet.BindColumns[0].CommandName = "Info";
in front of this line:

sheet.DataBind();