This is a migrated thread and some comments may be shown as answers.

Sharepoint Wdd3.0 web part that uses the RadGrid control

3 Answers 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul Barpha
Top achievements
Rank 1
Rahul Barpha asked on 16 May 2010, 11:18 AM
Hello ,

I want to create a Sharepoint Wdd3.0 web part that uses the RadGrid control. The grid needs to have add new / edit and delete record functionality. Similart to this example  http://sharepoint.telerik.com/Products/RadControlsAjax/Pages/RadGrid.aspx.

Is there any code sample that can help me to write the web part?

Thanks

Rahul V\Barpha.

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 17 May 2010, 04:19 PM
Hello Rahul,

I have responded to your ticket # 310134. Could you close the current one and leave the discussion to the afore-mentioned thread.

Thanks.

All the best,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rahul Barpha
Top achievements
Rank 1
answered on 19 May 2010, 01:39 PM
Hello ,

My Webpart code is :

 

RadGrid grid = new RadGrid();

 

 

private ScriptManager sm;

 

 

public GPSInfo()

 

{

 

this.ExportMode = WebPartExportMode.All;

 

}

 

protected override void OnLoad(EventArgs e)

 

{

 

this.EnsureChildControls();

 

}

 

protected override void CreateChildControls()

 

{

 

base.CreateChildControls();

 

 

if (ScriptManager.GetCurrent(this.Page) != null)

 

{

 

this.sm = ScriptManager.GetCurrent(this.Page);

 

}

 

else

 

{

 

this.sm = new ScriptManager();

 

 

this.Controls.Add(this.sm);

 

}

 

this.grid = new RadGrid();

 

 

this.Controls.Add(this.grid);

 

 

this.grid.AllowAutomaticDeletes = true;

 

 

this.grid.AllowAutomaticInserts = true;

 

 

this.grid.AllowAutomaticUpdates = true;

 

 

this.grid.AllowMultiRowEdit = true;

 

 

this.grid.AutoGenerateColumns = false;

 

 

this.grid.AutoGenerateDeleteColumn = true;

 

 

this.grid.AutoGenerateEditColumn = true;

 

 

if (this.Page.IsPostBack == false)

 

{

 

//SqlDataSource dataSource = new SqlDataSource("Data Source=ARDENT-07ET5GCW;Initial Catalog=WSS_Content_120;User ID=sa;Password=sa", "SELECT id,Name FROM InfoForm");

 

 

//dataSource.ID = "SqlDataSource1";

 

 

//this.grid.DataSourceID = "SqlDataSource1";

 

 

 

SqlDataSource dataSource = new SqlDataSource("Data Source=ARDENT-07ET5GCW;Initial Catalog=WSS_Content_120;User ID=sa;Password=sa", "SELECT id,Name FROM InfoForm");

 

 

//dataSource.UpdateCommand = "UPDATE testdata SET id=@id, Name=@Name WHERE id=@id";

 

 

//dataSource.DeleteCommand = "DELETE FROM testdata WHERE id=@id";

 

 

//dataSource.InsertCommand = "INSERT INTO testdata VALUES (id=@id, name=@name)";

 

 

this.grid.DataSource = dataSource;

 

 

this.grid.DataBind();

 

}

}

 

protected override void Render(System.Web.UI.HtmlTextWriter writer)

 

{

 

this.sm.RenderControl(writer);

 

 

this.grid.RenderControl(writer);

 

}

And my webConfig  coad is :

 

<

 

httpHandlers>

 

<!--

 

<add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2009.3.1314.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false" />-->

 

<

 

add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource,Telerik.Web.UI, Version=2009.1.311.35, Culture=neutral,PublicKeyToken=121fae78165ba3d4" verb="*" validate="false" />

 

</

 

httpHandlers>

 

<

 

assemblies>

 

<

 

add assembly="Telerik.Web.Design, Version=2009.3.1314.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />

 

</

 

assemblies>

 

<

 

SafeControls>

 

<

 

SafeControl Assembly="Telerik.Web.UI, Version=2009.1.311.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TypeName="*" Safe="True" />

 

<

 

SafeControl Assembly="Telerik.Web.UI, Version=2009.1.311.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.Design" TypeName="*" Safe="True" />

 

</

 

SafeControls>

 

0
Tsvetoslav
Telerik team
answered on 20 May 2010, 07:49 AM
Hi Rahul,

Have you gone through the following article and related help topics on integrating RadControls into Sharepoint:
http://www.telerik.com/help/aspnet-ajax/create-ajax-enabled-sharepoint-webpart-radcontrols.html

Do take a look at it and try implementing the following changes to your code:

1. Add the code to the OnInit event, needed for ajax to work properly with the web part.

2. Add the script manager control in the OnInit event as explained in the article.

3. Remove the EnsureChildControls from the OnLoad method - it is not needed.

4. Remove the Render method - and instead add both the grid and the SqlDataSource controls to the Controls collection of the web-part in the CreateChildControls() method.

5. Remove the call to the grid's DataBind() method from the CreateChildControls() method.

Hope it helps.

Regards,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Rahul Barpha
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Rahul Barpha
Top achievements
Rank 1
Share this question
or