protected void btnAddContextMenuItem_Click(object sender, EventArgs e) { // ExStart:AddContextMenuItem // Init context menu item command button CustomCommandButton cmd = new CustomCommandButton(); cmd.CommandType = CustomCommandButtonType.ContextMenuItem; cmd.Text = "MyNewContextMenuItem"; cmd.Command = "MyNewContextMenuItemCommand"; // Add context menu item command button to GridWeb GridWeb1.CustomCommandButtons.Add(cmd); // ExEnd:AddContextMenuItem }
protected void btnAddContextMenuItem_Click(object sender, EventArgs e) { // ExStart:AddContextMenuItem // Init context menu item command button CustomCommandButton cmd = new CustomCommandButton(); cmd.CommandType = CustomCommandButtonType.ContextMenuItem; cmd.Text = "MyNewContextMenuItem"; cmd.Command = "MyNewContextMenuItemCommand"; // Add context menu item command button to GridWeb GridWeb1.CustomCommandButtons.Add(cmd); // ExEnd:AddContextMenuItem }
protected void btnInitCommandButton_Click(object sender, EventArgs e) { // ExStart:InitCustomCommandButton // Instantiating a CustomCommandButton object CustomCommandButton button = new CustomCommandButton(); // Setting the command, text and image URL for button. Image should be relative to website root folder button.Command = "MyButton"; button.Text = "MyButton"; button.ImageUrl = "../Image/aspose.ico"; // Adding button to CustomCommandButtons collection of GridWeb GridWeb1.CustomCommandButtons.Add(button); // ExEnd:InitCustomCommandButton }
protected void btnInitCommandButton_Click(object sender, EventArgs e) { // ExStart:InitCustomCommandButton // Instantiating a CustomCommandButton object CustomCommandButton button = new CustomCommandButton(); // Setting the command, text and image URL for button. Image should be relative to website root folder button.Command = "MyButton"; button.Text = "MyButton"; button.ImageUrl = "../Image/aspose.ico"; // Adding button to CustomCommandButtons collection of GridWeb GridWeb1.CustomCommandButtons.Add(button); // ExEnd:InitCustomCommandButton }
protected void btnRemoveContextMenuItem_Click(object sender, EventArgs e) { // ExStart:RemoveContextMenuItem if (GridWeb1.CustomCommandButtons.Count > 1) { // Remove the 2nd custom command button or context menu item using remove at method GridWeb1.CustomCommandButtons.RemoveAt(1); } if (GridWeb1.CustomCommandButtons.Count >= 1) { // Access the 1st custom command button or context menu item and remove it CustomCommandButton custbtn = GridWeb1.CustomCommandButtons[0]; GridWeb1.CustomCommandButtons.Remove(custbtn); } // ExEnd:RemoveContextMenuItem }
private void InstantiateCustomCommandButton() { // Instantiating a CustomCommandButton object CustomCommandButton button = new CustomCommandButton(); // Setting the command for button button.Command = "MyButton"; // Setting text of the button button.Text = "MyButton"; // Setting image URL of the button, should be relative to website root folder button.ImageUrl = "../Image/aspose.ico"; // Adding button to CustomCommandButtons collection of GridWeb GridWeb1.CustomCommandButtons.Add(button); }
private void InstantiateCustomCommandButton() { // Instantiating a CustomCommandButton object CustomCommandButton button = new CustomCommandButton(); // Setting the command for button button.Command = "MyButton"; // Setting text of the button button.Text = "MyButton"; // Setting image URL of the button, should be relative to website root folder button.ImageUrl = "../Image/aspose.ico"; // Adding button to CustomCommandButtons collection of GridWeb GridWeb1.CustomCommandButtons.Add(button); }