
Embedding a RadMultiPage / RadTabStrip directly into a SharePoint web part works fine, but for code organization I would like to nest them into a separate control. Once I do this, the control re-creation doesn't work (at least, not the ways I have tried it :)). Specifically, when the RadMultiPage / RadTabStrip are part of the WebPartWithTelerik class (which inherits from System.Web.UI.WebControls.WebParts.WebPart), the RadGrid controls on each page allow editing correctly; however, when they are moved down into the WebPartPanel class, clicking Edit on the RadGrid on either page causes the entire page to re-load, and the controls are not in edit mode as their state has been lost.
Scenario:
* RadTabStrip / RadMultiPage combo with two RadPageView objects.
* Each RadPageView contains a single RadGrid which retrieves data via LinqToSql data sources.
* MOSS web site using VSEWSS 1.3 to build the web part in VS 2008.
I've tried a few iterations of this (attemping to serialize the container object, etc.) with no success. Here's hoping there's a simple fix out there.
Thanks,
William Cook
| using System; |
| using System.Runtime.InteropServices; |
| using System.Web.UI; |
| using System.Web.UI.WebControls; |
| using System.Web.UI.WebControls.WebParts; |
| using System.Xml.Serialization; |
| using Microsoft.SharePoint; |
| using Microsoft.SharePoint.WebControls; |
| using Microsoft.SharePoint.WebPartPages; |
| using Telerik.Web.UI; |
| namespace WebPartWithTelerik |
| { |
| [Guid("1d53c24d-161e-4fca-86b0-9a8f589e3ee9")] |
| public class WebPartWithTelerik : System.Web.UI.WebControls.WebParts.WebPart |
| { |
| private WebPartPanel Panel; |
| //{ |
| // get { return (WebPartPanel)ViewState["Panel"]; } |
| // set { ViewState["Panel"] = value; } |
| //} |
| public WebPartWithTelerik() |
| { |
| } |
| protected override void CreateChildControls() |
| { |
| base.CreateChildControls(); |
| // Add the controls to the page. |
| this.Panel = new WebPartPanel(); |
| this.Controls.Add(this.Panel); |
| } |
| } |
| public class WebPartPanel : Panel |
| { |
| private Telerik.Web.UI.RadMultiPage MultiPage; |
| //{ |
| // get { return (RadMultiPage)ViewState["MultiPage"]; } |
| // set { ViewState["MultiPage"] = value; } |
| //} |
| private Telerik.Web.UI.RadTabStrip TabStrip; |
| //{ |
| // get { return (RadTabStrip)ViewState["TabStrip"]; } |
| // set { ViewState["TabStrip"] = value; } |
| //} |
| public WebPartPanel() |
| { |
| this.ID = "WebPartPanelID"; |
| } |
| protected override void CreateChildControls() |
| { |
| base.CreateChildControls(); |
| // Create a simple label to validate rendering of controls. |
| Label label = new Label(); |
| label.Text = "Test web part for Telerik controls in a SharePoint web part."; |
| this.Controls.Add(label); |
| //this.ChildrenAsTriggers = true; |
| //this.UpdateMode = UpdatePanelUpdateMode.Conditional; |
| // Create two RadPageView objects. |
| RadPageView pageOne = new RadPageView(); |
| pageOne.ID = "pageOne"; |
| RadPageView pageTwo = new RadPageView(); |
| pageTwo.ID = "pageTwo"; |
| // Create the RadMultiPage object. |
| this.MultiPage = new RadMultiPage(); |
| this.MultiPage.ID = "multiPage"; |
| this.MultiPage.PageViewCreated += new RadMultiPageEventHandler(MultiPage_PageViewCreated); |
| this.MultiPage.PageViews.Add(pageOne); |
| this.MultiPage.PageViews.Add(pageTwo); |
| // Create the RadTab objects. |
| RadTab tabOne = new RadTab("One"); |
| tabOne.PageViewID = pageOne.UniqueID; |
| RadTab tabTwo = new RadTab("Two"); |
| tabTwo.PageViewID = pageTwo.UniqueID; |
| // Create the tabstrip. |
| this.TabStrip = new RadTabStrip(); |
| this.TabStrip.ID = "tabStrip"; |
| this.TabStrip.MultiPageID = this.MultiPage.UniqueID; |
| this.TabStrip.Tabs.Add(tabOne); |
| this.TabStrip.Tabs.Add(tabTwo); |
| // Add the controls to the page. |
| this.Controls.Add(this.TabStrip); |
| this.Controls.Add(this.MultiPage); |
| } |
| void MultiPage_PageViewCreated(object sender, RadMultiPageEventArgs e) |
| { |
| // Create a simple label to validate rendering of controls. |
| Label label = new Label(); |
| label.Text = e.PageView.ID; |
| e.PageView.Controls.Add(label); |
| LinqDataSource dataSource = new LinqDataSource(); |
| DataClassesDataContext context = new DataClassesDataContext(); |
| dataSource.ContextTypeName = context.GetType().AssemblyQualifiedName; //"WebPartWithTelerik.DataClassesDataContext, WebPartWithTelerik, Version=1.0.0.0, Culture=neutral, PublicKeyToken=23df81aee7a34b62"; |
| context.Dispose(); |
| dataSource.EnableInsert = true; |
| dataSource.EnableUpdate = true; |
| // Create the grid for the page. |
| RadGrid grid = new RadGrid(); |
| grid.AutoGenerateColumns = true; |
| grid.AutoGenerateEditColumn = true; |
| grid.AllowAutomaticInserts = true; |
| grid.AllowAutomaticUpdates = true; |
| grid.MasterTableView.DataKeyNames = new string[] { "TypeID" }; |
| switch (e.PageView.ID) |
| { |
| case "pageOne": |
| //dataSource.ID = "dataSourceOne"; |
| dataSource.TableName = "TableOnes"; |
| grid.ID = "gridOne"; |
| grid.NeedDataSource += new GridNeedDataSourceEventHandler(grid_NeedDataSourceOne); |
| break; |
| case "pageTwo": |
| //dataSource.ID = "dataSourceTwo"; |
| dataSource.TableName = "TableTwos"; |
| grid.ID = "gridTwo"; |
| grid.NeedDataSource += new GridNeedDataSourceEventHandler(grid_NeedDataSourceTwo); |
| break; |
| } |
| // Bind the data source. |
| //dataSource.DataBind(); |
| e.PageView.Controls.Add(dataSource); |
| // Add the grid to the PageView. |
| grid.DataSourceID = dataSource.UniqueID; |
| grid.MasterTableView.ID = grid.ID + "_MasterTableView"; |
| e.PageView.Controls.Add(grid); |
| } |
| void grid_NeedDataSourceOne(object source, GridNeedDataSourceEventArgs e) |
| { |
| RadGrid grid = (RadGrid)source; |
| grid.DataSourceID = "dataSourceOne"; |
| } |
| void grid_NeedDataSourceTwo(object source, GridNeedDataSourceEventArgs e) |
| { |
| RadGrid grid = (RadGrid)source; |
| grid.DataSourceID = "dataSourceTwo"; |
| } |
| } |
| } |
| webappteste.WebReferenceX.Service1 sd = new webappteste.WebReferenceX.Service1(); |
| DataSet ds = new DataSet(); |
| ds = sd.getClientes(); //Get full list of customers from a web service |
| DataTable dt = new DataTable("clientes"); |
| dt = ds.Tables[0]; |
| RadGrid1.DataSource = dt; |
| int asd = dt.Columns.Count; //Returns 58 columns - CORRECT |
| string tableName = ds.Tables[0].Columns[0].ToString(); //Returns the column name "CLIENTE" - CORRECT |
| int b = ds.Tables[0].Columns.Count; //Returns 58 columns - CORRECT |
| int a = RadGrid1.Columns.Count; //Return 0 columns - WRONG - Why not 58 columns??? |
| public DataSet getClientes() |
| { |
| SqlDataAdapter dataAdapter = new SqlDataAdapter("SELECT * FROM CLIENTES ORDER BY NOME",connections.retConn()) |
| DataSet dataSet = new DataSet(); |
| dataAdapter.Fill(dataSet); |
| return dataSet |
| } |
<asp:EntityDataSource ID="EntityDataSource1" runat="server"
ConnectionString="name=AllDataModels" DefaultContainerName="AllDataModels"
EntitySetName="Project" Select="it.[Name], it.[Identifier], it.[ID]">
</asp:EntityDataSource>
<
telerik:RadGrid ID="RadGrid1" runat="server"
style="z-index: 1; left: 9px; top: 122px; position: absolute;"
AllowSorting="True" DataSourceID="EntityDataSource1" GridLines="None"
AllowPaging="True">
<
MasterTableView AutoGenerateColumns="False" DataSourceID="EntityDataSource1">
<RowIndicatorColumn>
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="Name" HeaderText="Name" ReadOnly="True"
SortExpression="Name" UniqueName="Name">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Identifier" HeaderText="Identifier"
ReadOnly="True" SortExpression="Identifier" UniqueName="Identifier">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ID" DataType="System.Int32" HeaderText="ID"
ReadOnly="True" SortExpression="ID" UniqueName="ID">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
Thanks for any help you can give. :)
~wen

Example 1. The following code retrieves the actual visible text value from the combo (i.e. - trade, sell, rent)
a1 = document.getElementById("<%= ListTranType.ClientID %>").value;
alert(a1);
var b1 = $find("<%= ListTranType.ClientID %>");
alert(b1);
var b2 = b1.value;
alert(b2);
var b1 = $find("<%= ListTranType.ClientID %>").value;
alert(b1);
<
telerik:RadComboBox ID="ListTranType" OnClientSelectedIndexChanged="gettrantype" EnableEmbeddedSkins="true" Skin="Black" runat="server" Width="200px" ></telerik:RadComboBox>
I do have a script for capturing the value when the user selects one and it works fine as it is, but as said earlier sometimes the user will use the default value or not select one from the combo before clicking to proceed. Both of these actions are valid within the application. The code used to capture the value during the event is:
<script type="text/javascript">
var trantype;
function gettrantype(combo, eventArqs) {
var item = eventArqs.get_item();
trantypeval = item.get_value();
}