I have a grid with at most 10 rows. Each has a button (buttoncolumn) that will export that row's fields to CSV. I'm unable to export only the row when I click the button. It exports all the rows. I tried hiding the other rows but it didn't work.
protected void rgridAdp_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == "Export")
{
GridDataItem dataItem = e.Item as GridDataItem;
int batchId = StringHandlers.GetSafeInteger(dataItem["BatchNumber"].Text);
foreach (GridDataItem item in rgridAdp.MasterTableView.Items)
{
if (StringHandlers.GetSafeInteger(item["BatchNumber"].Text) == batchId)
{
item.Visible = true;
item.Display = true;
}
else
{
item.Display = false;
item.Visible = false;
}
}
rgridAdp.ExportSettings.FileName = "ADPExport-" + batchId;
rgridAdp.ExportSettings.ExportOnlyData = true;
rgridAdp.ExportSettings.OpenInNewWindow = true;
rgridAdp.MasterTableView.GetColumn("Export").Visible = false; // don't export button
rgridAdp.MasterTableView.ExportToCSV();