GridWeb Save Command

Hi,

At the moment my gridweb has a Save icon. I'd like the 'save' action to be done when the user clicks another button on the page - is this possible?

Thanks.

Hi,


Thanks for considering Aspose.

Well, when the GridWeb’s save button is clicked, SaveCommand event of the grid is fired. You can simply copy the code from GridWeb1_SaveCommand event handler to the click event handler of your .Net button. Or you may try to update the line of code…while initializing the button setting the delegate:
e.g
Sample code:

this.Button1.Click += new System.EventHandler(this.GridWeb1_SaveCommand);

Thank you.

Hi,I think there is a little confusion. There is no code in the save event:

protected void GridWeb1_SaveCommand(object sender, EventArgs e) {

    }</p><p>The gridweb shows a save icon.  When that is clicked something happens in the background, I need to replicate this 'something' whenenever another button is pressed,</p><p> i.e. within this event:       </p><p>protected void OnNextButtonClick(object sender, WizardNavigationEventArgs e)</p><p>{</p><p>}  </p>

Hi,


Well, GridWeb’s SaveComend event handler is used basically to save/export GridWeb’s data. Mind you have to have to write your own code in the event handler to process your requirements. If you set the SaveCommand event handler as blank (or you do not write any code segment into it), it will do nothing.

Thank you.

Ok, so if you wanted to save the data without clicking the save icon what would be the code?

Hi,


Moreover, if you do not write any code segment in the SaveCommand event, it will still do a post back action to notify server with some some key parameters for the server who can recognize what happened by the key parameters.

And to export or Save GridWeb’s data, you may write sample code like following:
e.g
Sample code:


// Generates a memory stream.
System.IO.MemoryStream ms = new System.IO.MemoryStream();

// Saves to the stream.
this.GridWeb1.WebWorksheets.SaveToExcelFile(ms);

// Sents the file to browser.
Response.ContentType = “application/vnd.ms-excel”;

//Adds header.
Response.AddHeader(“content-disposition”, “attachment; filename=book1.xls”);

// Writes file content to the response stream.
Response.OutputStream.Write(ms.GetBuffer(), 0, (int)ms.Length);

// OK.
Response.End();


Hope, this helps a bit.

Thank you.