<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" DataSourceID="SqlDataSource1" GridLines="None"> <ClientSettings> <Selecting AllowRowSelect="True" /> </ClientSettings> <MasterTableView AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource1"> <RowIndicatorColumn Visible="False"> </RowIndicatorColumn> <ExpandCollapseColumn Created="True"> </ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" FilterControlAltText="Filter ID column" HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID"> <ColumnValidationSettings> <ModelErrorMessage Text="" /> </ColumnValidationSettings> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="urun" FilterControlAltText="Filter urun column" HeaderText="urun" SortExpression="urun" UniqueName="urun"> <ColumnValidationSettings> <ModelErrorMessage Text="" /> </ColumnValidationSettings> </telerik:GridBoundColumn> </Columns> </MasterTableView></telerik:RadGrid>Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Dim c As Integer c = RadGrid1.MasterTableView.Items.CountEnd SubProtected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender If (RadGrid1.MasterTableView.Items.Count > 0) Then If (RadGrid1.SelectedItems.Count = 0) Then RadGrid1.MasterTableView.Items(0).Selected = True End If End IfEnd SubRadDatePicker1.SelectedDate = DateTime.ParseExact(dateToConvert, "yyyyMMdd", CultureInfo.InvariantCulture);<telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True"> </telerik:RadGrid>
<telerik:GridDropDownColumn DataField="CustomerID" DataType="System.String" DataSourceID="SqlDataSource4" FilterControlAltText="Filter CustomerName column" HeaderText="Customer Name" ListTextField="Name" ListValueField="ID" SortExpression="Name" UniqueName="CustomerName"> <ColumnValidationSettings><asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:NameOfString %>" SelectCommand="SELECT [Name], [ID] FROM [Customer] ORDER BY [Name]"></asp:SqlDataSource>I have a RadMultiPage with several pageviews, each of which is tied to a specific tab in a RadTabStrip. When the page loads I programmatically determine which tabs are accessible, and hide the rest. I then iterate over the pageviews in the associated RadMultiPage to mark them visible if the tab is also visible. Once that's done I check if there are any visible tabs, and if there are I set the selectedindex of both the tabstrip and the multipage to 0.
The tabs are showing/hiding correctly, but the multipage pageviews are not. If the first tab/pageview is not visible the tab is gone, but the pageview still shows. If I set all of the pageviews to visible=false but leave the tabs visible I can click through all the tabs and their pageviews load which is not what I expect.
If a control is set to "Visible=false" I would expect it to be completely removed from the server side and have no possibility to render. Why is this not happening? Here's some of the relevant code:
<telerik:RadTabStrip ID="tabs" runat="server" MultiPageID="pages" AutoPostBack="true" ShowBaseLine="true" Align="Right"><Tabs><telerik:RadTab Text="Tab1" PageViewID="Page1" Value="Tab1" Visible="false" /><telerik:RadTab Text="Tab2" PageViewID="Page2" Value="Tab2" Visible="false" /></Tabs></telerik:RadTabStrip><telerik:RadMultiPage ID="pages" runat="server" RenderSelectedPageOnly="true"><telerik:RadPageView ID="Page1" runat="server">...
tabs.FindTabByValue("Tab1").Visible = HasPermission("Tab1");tabs.FindTabByValue("Tab2").Visible = HasPermission("Tab2");... foreach (RadTab tab in tabs.Tabs){pages.FindPageViewByID(tab.PageViewID).Visible = tab.Visible;}if (tabs.Tabs.Count(x => x.Visible) > 0){tabs.SelectedIndex = 0;pages.SelectedIndex = 0;}
// ctrlInput.ascx.cs// consists of several controls (dropdown lists, checkboxes and a submit button) public event EventHandler BtnClickEvent;protected void Btn_Click(object sender, EventArgs e){ BtnClickEvent(this, e);}//ctrlRadGrid.ascx.cs//display result table based on ctrlInput values public event EventHandler MyGridNeedDataSource; protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e){ MyGridNeedDataSource(this, e);}// MyPage.aspx.cx protected void Page_Init(object sender, EventArgs e){ ctrlInput1.BtnClickEvent += new EventHandler(Foo_btnClickEvent); ctrlRadGrid1.MyGridNeedDataSource += new EventHandler(myGrid_NeedDataSource);} protected void Page_Load(object sender, EventArgs e){ // toggle panel visibility if (!IsPostBack) { pnlInputs.Visible = true; pnlResults.Visible = false; } else { pnlInputs.Visible = false; pnlResults.Visible = true; }} protected void myGrid_NeedDataSource(object sender, EventArgs e){ if (ViewState["MyParams"] != null)
{
myGrid.DataSource = GetData(ViewState["MyParams"]);
}} protected void Foo_btnClickEvent(object sender, EventArgs e){ var ctrl = (ctrlInput)sender;
ViewState["MyParams"] = ctrl.InputParams;}private DataTable GetData(string param){ //DONE: call stored procedure with param}