Yeah... I thought of that, however I debugged it and inspected the attributes at various points in the life cycle. They seem to be zero all the time. Here is the skeletal logic:
//during init, I sneak in a couple of buttons (added a place-holder to the UIPager)
**protected override void OnInit(EventArgs e)**
{
try
{
base.OnInit(e);
List<Button> listActions = new List<Button>();
Button firstButton = new Button();
firstButton.ID = "btnPublishAll";
firstButton.ControlStyle.CssClass = "btn btn-primary";
firstButton.Text = "Publish Selected";
firstButton.CommandName = "PUBLISH";
firstButton.Click += new EventHandler(action_Click);
listActions.Add(firstButton);
//add action buttons to the header of the Grid
Grid.PagerWithActions.AddActions(listActions);
// Unigrid initialization
Grid.OnExternalDataBound += DoDataBound;
Grid.OnDataReload += GetDataSet;
}
//the handler for the buttons
**protected void action_Click(object sender, EventArgs e)**
{
try
{
Button buttClicked = sender as Button;
if (buttClicked == null)
return;
var rows = Grid.SelectedItems;
List<string> additions = Grid.NewlySelectedItems;
List<string> removals = Grid.DeselectedItems;
if (buttClicked.CommandName.Equals("PUBLISH"))
//do something with the selection here;
if (buttClicked.CommandName.Equals("UNPUBLISH"))
;
}
catch (Exception ex) {ShowError(ex);}
}
**protected override void OnLoad(EventArgs e)**
{
try {
base.OnLoad(e);
if (StopProcessing)
return;
Grid.ReloadData();
}
catch (Exception ex) {
StopProcessing = true;
ShowAlert("Error.", ex.Message);
}
}
//and here is where I handle my ExternalDataBound event
**private object DoDataBound(object sender, string sourceName, object parameter)**
{
var row = parameter as DataRowView;
if (row == null)
return null;
switch (sourceName.ToLower())
{
case "eventname":
//Preview Event
dataCell.CssClass = "coleventname";
link = new HyperLink()
{
Text = eventName,
NavigateUrl = "javascript:void(0)"
};
case "date":
dataCell.CssClass = "coldate";
return seatingStartDateTime.Value.ToString("ddd MMM d, yyyy");
etc. etc.
. . .
}
}