Webpart

Greeting Aspose Team!

Building on the webcontrol you help me with, I've tried to make a webpart.
I tough the process will be straigh foward. It is, like the code attach show.
But nothing I did make it work.
The grid load correctly, the event fires.
But, on post back, the grid do not load the client data.
So the event are just acting weird.
(ex: grid.ActiveCell is always null even if I select a cell
(same for sheet.datasource

Can you help me with this issue?
Thanks for any help.

Hi,

We will get back to you soon for your issue.

Thanks for being patient!

Hi,

Could you please upload your source files here?

Hi,

Thanks for yout help.
Here is the source file.

Hi,

Do you use the webpart in SharePoint? Since we don't have a SharePoint environment, we can only test the webpart in common asp.net applications, and it seems to work fine. We will do more test and give the solution soon.

Thank you for being patient.

Hi,
I'm effectively using the webpart in a SharePoint environment.
Thanks for your continuous help.

Hi,

We need more information about your sharepoint environment such as OS version, IIS version, SharePoint version, .net version, and web.config. And please tell us how you use your webpart in the sharepoint server.

Thank you.

Hi,
I use windows server 2003 standard edition sp2, IIS 6.0, WSS 3.0, .Net 2.0.
I've attach my web.config

To use my webpart in sharepoint, I do the following steps:
A)
1. compile the dll with a strong name
2. add the dll to the GAC
3. add the following line in the web.config in the 'SharePoint/SafeControls' section:

4. do a IIS reset
B) Now, in my sharpoint site, I :
1. click on 'Site Actions/Site Settings'
2. In the 'Galleries' column, I click on 'Web Parts'
3. I click 'New'
4. I locate the webpart in the list, check it, and click 'Populate Gallery'
C) Now, to use the webpart, I :
1. click on 'Site Actions/Create'
2. In the 'Librairies' column, I click on 'Document Library'
3. I give it a name and, in the 'Document Template' section, I choose 'Web Part Page'
4. I click 'New'
5. give it a name and, in the 'Layout' section, I choose 'Full Page, Vertical'
6. I click 'Add a Web Part'
7. I scroll the list to find my web part, check it, and click 'Add'
8. I then click 'Exit Edit Mode'
The page is now ready.

A last thing I do.
Whenever I change the code of the webpart.
To load it in sharepoint, I repeat step (A.2) and (A.4) only.

Hi,

Could you post the web.config again? I can't see it.

Thank you.

Hi,
I've attach the web.config.
Thanks for your support.

I've forget to mention one thing on how I use the webpart.
I also put the Aspose.Grid.Web dll in the GAC

Hi,

I found a machine which has been already installed a sharepoint server 2.0. But I can't add the awptest webpart into its gallery. I think that the SS 3.0 is required to use the webpart control. I will build an SS 3.0 environment.

Thank you for being patient.

Hi,

We have found a way to fix this problem.

1. The grid should use SessionMode.ViewState to keep it's state data.

2. The IsPostBack property can't be used to determine whether to Initialized the grid. So I use the grid's Submit button to initialize the grid.

3. Set the XhtmlMode to false.

Here is the modified code:

awptest.cs:

------------------------------------------------------------------

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using System.Web.UI.HtmlControls;

using Aspose.Grid.Web;
using Aspose.Grid.Web.Data;
using System.Data;
using System.Web.UI.WebControls.WebParts;

namespace awptest
{

[XmlRoot(Namespace = "awptest")]
public class awptest : WebPart
{
private GridWeb grid;

protected override void CreateChildControls()
{
base.CreateChildControls();

grid = new GridWeb();
grid.ID = "InnerGrid";
grid.XhtmlMode = false;
grid.SessionMode = SessionMode.ViewState;
grid.SubmitCommand += new WorkbookEventHandler(grid_SubmitCommand);
grid.CustomCommand += new CustomCommandEventHandler(grid_CustomCommand);

Controls.Add(grid);

//if (!Page.IsPostBack)
// InitGrid();
}

private void InitGrid()
{
grid.EditMode = false;

//creating custom buttons
CustomCommandButton cmdChoose = new CustomCommandButton();
cmdChoose.ImageUrl = "/agw_client_debug/save.gif";
cmdChoose.Command = "Choose";
cmdChoose.ToolTip = "Choose";
grid.CustomCommandButtons.Add(cmdChoose);

//init the grid with dataset 0
WebWorksheet sheet = grid.WebWorksheets[0];
DataTable data0 = new DataTable();
data0.Columns.Add("data0");
data0.Rows.Add(new object[] { "0" });
data0.Rows.Add(new object[] { "0" });
sheet.DataSource = data0;
sheet.CreateAutoGenratedColumns();
sheet.DataBind();
}

protected void grid_SubmitCommand(object sender, EventArgs e)
{
InitGrid();
}

private void grid_CustomCommand(object sender, string command)
{
string key = null;
if (grid.ActiveCell != null)
key = (string)grid.ActiveCell.Value;
else
key = "data0";

WebWorksheet sheet = grid.WebWorksheets[0];

//command cases:
if (command == "Choose")
{
//display a choice of dataset for the user to select one
DataTable choice = new DataTable();
sheet.Cells.Clear();
choice.Columns.Add("select one");
choice.Rows.Add(new object[] { "data0" });
choice.Rows.Add(new object[] { "data1" });
sheet.DataSource = choice;
sheet.CreateAutoGenratedColumns();
sheet.DataBind();
grid.CustomCommandButtons[0].Command = "Display";
grid.CustomCommandButtons[0].ToolTip = "Display";
}

if (command == "Display" & key == "data0")
{
//display datset 0
DataTable data0 = new DataTable();
sheet.Cells.Clear();
data0.Columns.Add("data0");
data0.Rows.Add(new object[] { "0" });
data0.Rows.Add(new object[] { "0" });
sheet.DataSource = data0;
sheet.CreateAutoGenratedColumns();
sheet.DataBind();
grid.CustomCommandButtons[0].Command = "Choose";
grid.CustomCommandButtons[0].ToolTip = "Choose";
}

if (command == "Display" & key == "data1")
{
//display dataset 1
DataTable data1 = new DataTable();
sheet.Cells.Clear();
data1.Columns.Add("data1");
data1.Rows.Add(new object[] { "1" });
data1.Rows.Add(new object[] { "1" });
sheet.DataSource = data1;
sheet.CreateAutoGenratedColumns();
sheet.DataBind();
grid.CustomCommandButtons[0].Command = "Choose";
grid.CustomCommandButtons[0].ToolTip = "Choose";
}
}
}
}

I found that to replace the awptest.dll with the SS3.0, I have to remove the webpart, and the pages that contain the webpart. Then I modifie the assembly.cs to upgrage the dll's version number, and rebuild the dll. Then I remove the old dll from the GAC cache and add the new one. Next I open the web.config and modify the "safecontrols" settings with this control's assembly version number. At last I restart the IIS. These steps ensure that the SS3.0 load the new dll correctly.

Thanks.

Thank you, very very much.
You completly solve my issue.
The grid is now perfectly integrating with SharePoint.
Once again proving how versatile your control is.
Thank you for such great support. You really are the best.