Hi,
I have a user control "test.ascx" which has editable rad grid. In the aspx page, i have a rad tab-strip and radpageview. What am doing here is to add a user control dynamically (test.ascx) dynamically and adding this to multiple rad tabs. Now, any time i click on radgrid "Edit" (which is present in the user control), entire page gets lost on postback. I looked at couple of articles that was there that said to reload the controls since we are binding dynamically. But it didn't help.
Your timely help is appreciated.
Test.ascx
Test.ascx.cs:
Default.aspx.cs:
Regards,
Kishan G K
I have a user control "test.ascx" which has editable rad grid. In the aspx page, i have a rad tab-strip and radpageview. What am doing here is to add a user control dynamically (test.ascx) dynamically and adding this to multiple rad tabs. Now, any time i click on radgrid "Edit" (which is present in the user control), entire page gets lost on postback. I looked at couple of articles that was there that said to reload the controls since we are binding dynamically. But it didn't help.
Your timely help is appreciated.
Test.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Test.ascx.cs" Inherits="WebApplication4.Test" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><h4> Scenario Lab Management</h4><asp:Label ID="lblId" runat="server"></asp:Label>:<asp:Label ID="lblValue" runat="server"></asp:Label><telerik:RadGrid ID="radSIFMAHypotheticalMaintenance" runat="server" AutoGenerateColumns="False" PageSize="25" AllowAutomaticUpdates="True"> <MasterTableView Width="100%" PageSize="25" AutoGenerateColumns="False"> <Columns> <telerik:GridButtonColumn ButtonType="LinkButton" UniqueName="EditCommandColumn" CommandName="Edit" Text="Edit" /> <telerik:GridBoundColumn DataField="MaturityType" HeaderText="Maturity" SortExpression="" ReadOnly="true" /> <telerik:GridBoundColumn DataField="Sequence" HeaderText="Sequence" SortExpression="" ReadOnly="true" /> <telerik:GridNumericColumn UniqueName="SIFMA" SortExpression="SIFMA" HeaderText="SIFMA" DataType="System.Decimal" DataField="Rate" ColumnEditorID="GridNumericColumnEditor1"> </telerik:GridNumericColumn> </Columns> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="true" /> </ClientSettings></telerik:RadGrid><telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server"> <NumericTextBox MaxLength="25" EmptyMessage="Percentage."> <NumberFormat GroupSeparator="" DecimalDigits="2" /> </NumericTextBox></telerik:GridNumericColumnEditor><telerik:RadGrid ID="radLIBOR" runat="server" AutoGenerateColumns="False" PageSize="25"> <MasterTableView Width="100%" CommandItemDisplay="None" PageSize="25" AutoGenerateColumns="False" EditMode="EditForms"> <Columns> <telerik:GridButtonColumn ButtonType="LinkButton" UniqueName="EditCommandColumn" CommandName="Edit" Text="Edit" /> <telerik:GridBoundColumn DataField="maturityType" HeaderText="Maturity" SortExpression="" ReadOnly="true" /> <telerik:GridBoundColumn HeaderText="Sequence" DataField="sequence" SortExpression="" ReadOnly="true" /> <telerik:GridNumericColumn UniqueName="LIBOR" SortExpression="LIBOR" HeaderText="LIBOR" DataType="System.Decimal" DataField="rate" ColumnEditorID="GridNumericColumnEditor2"> </telerik:GridNumericColumn> </Columns> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="true" /> </ClientSettings></telerik:RadGrid><telerik:GridNumericColumnEditor ID="GridNumericColumnEditor2" runat="server"> <NumericTextBox MaxLength="25" EmptyMessage="Percentage."> <NumberFormat GroupSeparator="" DecimalDigits="2" /> </NumericTextBox></telerik:GridNumericColumnEditor>Test.ascx.cs:
using System;namespace WebApplication4{ public partial class Test : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } public void LoadData(TestData td) { lblId.Text = td.id.ToString(); lblValue.Text = td.var1.ToString(); radSIFMAHypotheticalMaintenance.DataSource = td.sifmaList; radLIBOR.DataSource = td.liborList; radSIFMAHypotheticalMaintenance.DataBind(); radLIBOR.DataBind(); } }}Default.aspx:
<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication4._Default" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title></title></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <telerik:RadTabStrip ID="RadTabStrip1" Width="100%" runat="server" MultiPageID="RadMultiPage1" SelectedIndex="0"> </telerik:RadTabStrip> <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0"> </telerik:RadMultiPage> </form></body></html>Default.aspx.cs:
using System;using System.Collections.Generic;using Telerik.Web.UI;namespace WebApplication4{ public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { List<TestData> lst = DataSetUp(); foreach (var item in lst) { RadTab tab = new RadTab(); tab.Text = item.tabName; tab.PageViewID = item.id.ToString(); RadTabStrip1.Tabs.Add(tab); RadPageView pageView = new RadPageView(); pageView.ID = item.id.ToString(); Test userControl = this.LoadControl("~/Test.ascx") as Test; userControl.LoadData(item as TestData); pageView.Controls.Add(userControl); RadMultiPage1.PageViews.Add(pageView); } } } private static List<TestData> DataSetUp() { List<TestData> lst = new List<TestData>(); List<LIBOR> liborLst = new List<LIBOR>(); liborLst.Add(new LIBOR { maturityType = "Weekly", rate = 25.5, sequence = 100 }); liborLst.Add(new LIBOR { maturityType = "Monthly", rate = 35.5, sequence = 1001324 }); List<SIFMA> sifmaLst = new List<SIFMA>(); sifmaLst.Add(new SIFMA { maturityType = "Weekly", rate = 45.5, sequence = 1000 }); sifmaLst.Add(new SIFMA { maturityType = "Monthly", rate = 55.5, sequence = 10013240 }); var test = new TestData { id = 1, tabName = "10 Year Average", var1 = "string1", var2 = "string11", liborList = liborLst, sifmaList = sifmaLst }; lst.Add(test); List<LIBOR> liborLst2 = new List<LIBOR>(); liborLst2.Add(new LIBOR { maturityType = "Quarterly", rate = 65.5, sequence = 10 }); liborLst2.Add(new LIBOR { maturityType = "Yearly", rate = 75.5, sequence = 10013 }); List<SIFMA> sifmaLst2 = new List<SIFMA>(); sifmaLst2.Add(new SIFMA { maturityType = "Quarterly", rate = 85.5, sequence = 1 }); sifmaLst2.Add(new SIFMA { maturityType = "Yearly", rate = 95.5, sequence = 100 }); var test2 = new TestData { id = 2, tabName = "1987 Crash", var1 = "string2", var2 = "string22", liborList = liborLst2, sifmaList = sifmaLst2 }; lst.Add(test2); return lst; } } public class TestData { public int id; public string tabName; public string var1; public string var2; public List<LIBOR> liborList; public List<SIFMA> sifmaList; } public class LIBOR { public string maturityType; public double rate; public int sequence; public string MaturityType { get { return maturityType; } } public double Rate { get { return rate; } } public int Sequence { get { return sequence; } } } public class SIFMA { public string maturityType; public double rate; public int sequence; public string MaturityType { get { return maturityType; } } public double Rate { get { return rate; } } public int Sequence { get { return sequence; } } }}Regards,
Kishan G K