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

Loading user contrl with radgrid + RadWindow

1 Answer 55 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ceki Granti
Top achievements
Rank 1
Ceki Granti asked on 05 Dec 2008, 06:15 AM
Hi,

Using VS2005
I have 2 strange problem with RadGrid 2008/Q2 and radwindow,

When I dynamically load some user controls which consists paged radgrid with code below:
1- First click to treeview node loads the control succesfully, then paging is working succesfully.
Clicking to another node, loads the uc succesfully again, but when you click to pager to see 2nd page on the radgrid, nothing happens. But after clicking the pager again moves to the desired page?? I tried to use slider for the paging, however it gave me java error for first try, and second try to move it again was succesful

For the radwindow:
2- When I click to an item in grid(in user control), it should open a radwindow, however now its giving javascript error (object ecpected??) I couldn't find out which I'm missing.. :)

Your help will be very appreciated.
Thanks.

p.s.: The codes of default.aspx and one of the user control which I'm using are below. Other uc's are very similar to each other
p.s.:I have RadScriptManager in Masterpage..


Default.aspx

<%

@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/MasterPage.Master" CodeBehind="Default.aspx.vb" Inherits="Crm._Default"%>

 

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

 

<

 

asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

 

<

 

telerik:RadSplitter ID="RadSplitter1" runat="server" Height="100%" Width="929px" Skin="Web20">

 

 

<telerik:RadPane ID="Radpane1" runat="server" Width="160px">

 

 

<span class="SplitterPaneHeader">Ana Menu</span>

 

 

<telerik:RadTreeView ID="RadTreeView1" runat="server" OnNodeClick="RadTreeView1_NodeClick">

 

 

<Nodes>

 

 

<telerik:RadTreeNode runat="server" Text="Companies" Value="Firmalar">

 

 

</telerik:RadTreeNode>

 

 

<telerik:RadTreeNode runat="server" Text="Meetings">

 

 

 

</telerik:RadTreeNode>

 

 

<telerik:RadTreeNode runat="server" Text="Quotes" Value="Teklifler">

 

 

</telerik:RadTreeNode>

 

 

<telerik:RadTreeNode runat="server" Text="Orders">

 

 

 

</telerik:RadTreeNode>

 

 

<telerik:RadTreeNode runat="server" Text="Services" Value="TeknikServis">

 

 

</telerik:RadTreeNode>

 

 

</Nodes>

 

 

<CollapseAnimation Duration="100" Type="OutQuint" />

 

 

<ExpandAnimation Duration="100" />

 

 

</telerik:RadTreeView>

 

 

</telerik:RadPane>

 

 

 

<telerik:RadSplitBar ID="Radsplitbar5" runat="server" CollapseMode="Forward"></telerik:RadSplitBar>

 

 

<telerik:RadPane ID="Radpane2" runat="server">

 

 

<span class="SplitterPaneHeader">Detay</span>

 

 

<asp:UpdatePanel ID="RadGridUpdatePanel" UpdateMode="Conditional" runat="server">

 

 

<Triggers>

 

 

<asp:AsyncPostBackTrigger ControlID="RadTreeView1" />

 

 

</Triggers>

 

 

<ContentTemplate>

 

 

<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>

 

 

</ContentTemplate>

 

 

</asp:UpdatePanel>

 

 

</telerik:RadPane>

 

 

</telerik:RadSplitter>

 

 

<telerik:RadWindowManager ID="RadWindowManager1" runat="server" ReloadOnShow="true" ShowContentDuringLoad="false" VisibleStatusbar="false" Width="420px" Height="440px" Modal="true" Skin="Web20"></telerik:RadWindowManager>

 

</

 

asp:Content>

Default.aspx.vb

 

Public

 

Partial Class _Default

 

 

Inherits System.Web.UI.Page

 

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

 

If Not String.IsNullOrEmpty(LastLoadedControl) Then

 

 

 

 

LoadUserControl(LastLoadedControl)

 

End If

 

 

 

 

 

End Sub

 

 

 

 

 

Protected Sub RadTreeView1_NodeClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs)

 

LoadUserControl(e.Node.Value.ToString)

 

End Sub

 

 

 

 

 

Private Property LastLoadedControl() As String

 

 

 

 

 

Get

 

 

 

 

 

Return TryCast(ViewState("LastLoaded"), String)

 

 

End Get

 

 

 

 

 

Set(ByVal value As String)

 

ViewState(

"LastLoaded") = value

 

 

End Set

 

 

 

 

 

End Property

 

 

 

 

 

Private Sub LoadUserControl(ByVal ctrlName As String)

 

PlaceHolder1.Controls.Clear()

 

Dim uc As UserControl = DirectCast(LoadControl("~/UserControls/" & ctrlName & ".ascx"), UserControl)

 

PlaceHolder1.Controls.Add(uc)

LastLoadedControl = ctrlName

 

End Sub

 

End

 

Class

~/UserControls/TeknikServis.ascx

 

<%

@ Control Language="vb" AutoEventWireup="false" CodeBehind="TeknikServis.ascx.vb" Inherits="Crm.TeknikServis1" %>

 

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

 

 

 

 

<

 

script type="text/jscript">

 

 

 

 

 

 

function

 

openRadWindow(Id,Mode)

 

{

 

var oWnd = radopen("./Detay/ServisDetay.aspx?TeknikServisId=" +Id+ "&Mode=" + Mode, null );

 

oWnd.center();

}

 

 

 

 

 

</script>

 

 

 

 

 

 

 

<

 

div>

 

 

 

 

 

<telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True"

 

 

 

 

 

AutoGenerateColumns="False" GridLines="None" Height="85%" PageSize="10" Skin="Vista"

 

 

 

 

 

AllowPaging="True" Font-Bold="False" BorderStyle="None" DataSourceID="SqlDataSource1">

 

 

 

 

 

<PagerStyle Mode="Slider" Font-Names="Arial" Font-Size="12px" HorizontalAlign="Center" />

 

 

 

 

 

<MasterTableView DataKeyNames="TeknikServisId" CommandItemDisplay="Top" DataSourceID="SqlDataSource1">

 

 

 

 

 

<RowIndicatorColumn>

 

 

 

 

 

<HeaderStyle Width="20px" />

 

 

 

 

 

</RowIndicatorColumn>

 

 

 

 

 

<ExpandCollapseColumn>

 

 

 

 

 

<HeaderStyle Width="20px" />

 

 

 

 

 

</ExpandCollapseColumn>

 

 

 

 

 

<CommandItemTemplate>

 

 

 

 

 

<div style="height: 20px; margin-top: 4px; font: Arial; font-size: 12px; font-weight: bold">

 

 

 

 

 

<asp:LinkButton runat="server" ID="LinkButton1" Text="Yeni" CommandName="Yeni" OnClientClick="openRadWindow('0','Add'); return false;" />

 

 

 

 

 

</div>

 

 

 

 

 

</CommandItemTemplate>

 

 

 

 

 

<Columns>

 

 

 

 

 

<telerik:GridTemplateColumn DataField="TeknikServisId" DataType="System.Int32" HeaderText="No"

 

 

 

 

 

SortExpression="TeknikServisId" UniqueName="TeknikServisId" FilterControlWidth="25px">

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

 

<

 

a href="#" onclick="openRadWindow('<%#DataBinder.Eval(Container.DataItem,"TeknikServisId")%>','Edit'); return false;">

 

 

 

 

<%

# Eval("TeknikServisId") %>

 

 

</a>

 

 

 

 

 

</ItemTemplate>

 

 

 

 

 

<HeaderStyle HorizontalAlign="Center" Width="50px" />

 

 

 

 

 

<ItemStyle HorizontalAlign="Center" />

 

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

 

<telerik:GridBoundColumn DataField="Tarih" DataType="System.DateTime" EmptyDataText="&amp;nbsp;"

 

 

 

 

 

HeaderText="Tarih" SortExpression="Tarih" UniqueName="Tarih" FilterControlWidth="95px">

 

 

 

 

 

<HeaderStyle Width="120px" />

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

<telerik:GridBoundColumn DataField="FirmaAdi" EmptyDataText="&amp;nbsp;" FilterControlWidth="275px"

 

 

 

 

 

HeaderText="Firma Adı" SortExpression="FirmaAdi" UniqueName="FirmaAdi">

 

 

 

 

 

<HeaderStyle Width="300px" />

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

<telerik:GridBoundColumn DataField="BildirilenAriza" EmptyDataText="&amp;nbsp;" FilterControlWidth="275px"

 

 

 

 

 

HeaderText="Bildirilen Arıza" SortExpression="BildirilenAriza" UniqueName="BildirilenAriza">

 

 

 

 

 

<HeaderStyle Width="300px" />

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

<telerik:GridBoundColumn DataField="SeriNo" EmptyDataText="&amp;nbsp;" FilterControlWidth="75px"

 

 

 

 

 

HeaderText="Seri No" SortExpression="SeriNo" UniqueName="SeriNo">

 

 

 

 

 

<HeaderStyle Width="100px" />

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

<telerik:GridBoundColumn DataField="Marka" EmptyDataText="&amp;nbsp;" FilterControlWidth="75px"

 

 

 

 

 

HeaderText="Marka" SortExpression="Marka" UniqueName="Marka">

 

 

 

 

 

<HeaderStyle Width="100px" />

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

<telerik:GridBoundColumn DataField="UrunTipi" EmptyDataText="&amp;nbsp;" FilterControlWidth="75px"

 

 

 

 

 

HeaderText="&#220;r&#252;n Tipi" SortExpression="UrunTipi" UniqueName="UrunTipi">

 

 

 

 

 

<HeaderStyle Width="100px" />

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

<telerik:GridBoundColumn DataField="TeknikServisDurumu" EmptyDataText="&amp;nbsp;"

 

 

 

 

 

FilterControlWidth="75px" HeaderText="Durumu" SortExpression="TeknikServisDurumu"

 

 

 

 

 

UniqueName="TeknikServisDurumu">

 

 

 

 

 

<HeaderStyle Width="100px" />

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

</Columns>

 

 

 

 

 

<AlternatingItemStyle BackColor="#FFFFC8" Font-Bold="False" Font-Italic="False" Font-Overline="False"

 

 

 

 

 

Font-Names="Arial" Font-Size="12px" Font-Strikeout="False" Font-Underline="False"

 

 

 

 

 

Wrap="True" />

 

 

 

 

 

</MasterTableView>

 

 

 

 

 

<HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"

 

 

 

 

 

Font-Underline="False" Height="14px" Wrap="True" Font-Names="Arial" Font-Size="12px" />

 

 

 

 

 

<ClientSettings AllowKeyboardNavigation="True">

 

 

 

 

 

<Scrolling AllowScroll="True" UseStaticHeaders="True" />

 

 

 

 

 

<ClientMessages PagerTooltipFormatString="Sayfa: &lt;b&gt;{0}&lt;/b&gt; - &lt;b&gt;{1}&lt;/b&gt;" />

 

 

 

 

 

</ClientSettings>

 

 

 

 

 

<FilterMenu EnableTheming="True" Skin="Vista">

 

 

 

 

 

<CollapseAnimation Duration="200" Type="OutQuint" />

 

 

 

 

 

</FilterMenu>

 

 

 

 

 

<FooterStyle Font-Names="Arial" Font-Size="12px" />

 

 

 

 

 

<AlternatingItemStyle Font-Names="Arial" Font-Size="12px" />

 

 

 

 

 

<ItemStyle Font-Names="Arial" Font-Size="12px" />

 

 

 

 

 

</telerik:RadGrid>

 

 

 

 

 

</div>

 

 

 

 

 

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Crm2009ConnectionString %>"

 

 

 

 

 

SelectCommand="SELECT TeknikServis.TeknikServisId, TeknikServis.Tarih, Firmalar.FirmaAdi, TeknikServis.BildirilenAriza, TeknikServis.SeriNo, Tanimlar_Markalar.Marka, Tanimlar_UrunTipleri.UrunTipi, Tanimlar_TeknikServisDurumlari.TeknikServisDurumu FROM TeknikServis LEFT OUTER JOIN Firmalar ON TeknikServis.FirmaId = Firmalar.FirmaId LEFT OUTER JOIN Tanimlar_Markalar ON TeknikServis.MarkaId = Tanimlar_Markalar.MarkaId LEFT OUTER JOIN Tanimlar_UrunTipleri ON TeknikServis.UrunTipiId = Tanimlar_UrunTipleri.UrunTipiId LEFT OUTER JOIN Tanimlar_TeknikServisDurumlari ON TeknikServis.TeknikServisDurumId = Tanimlar_TeknikServisDurumlari.TeknikServisDurumId ORDER BY TeknikServis.Tarih"

 

 

 

 

 

DataSourceMode="DataReader"></asp:SqlDataSource>

 

 

 

 

 

<telerik:RadWindowManager ID="RadWindowManager1" runat="server" Height="600px" Skin="Vista"

 

 

 

 

 

VisibleStatusbar="False" Width="850px" Behaviors="Close, Move">

 

 

 

 

 

<Windows>

 

 

 

 

 

<telerik:RadWindow ID="TeknikServisDetay" runat="server" Style="display: none;" InitialBehavior="None"

 

 

 

 

 

Left="" NavigateUrl="" Top="" Behavior="Default">

 

 

 

 

 

</telerik:RadWindow>

 

 

 

 

 

</Windows>

 

 

 

 

 

</telerik:RadWindowManager>

~/UserControls/TeknikServis.ascx.vb
No code

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Sebastian
Telerik team
answered on 05 Dec 2008, 09:11 AM
Hi Ceki,

Onto your question:

  1. Can you please verify that you load the user controls programmatically in par with the concepts depicted in this article from the documentation? It seems that the grid is rebound one step behind which might be caused by improper user control viewstate persistence/load.
  2. I suppose that the javascript which has to be executed and open the RadWindow instance generates an error at some point. Have you debugged the jscript exception to see where the issue is nested? You may also try casting the value returned from the binding expression of the anchor to string to see whether this makes a difference, namely:

    <href="#" onclick="openRadWindow('<%#DataBinder.Eval(Container.DataItem,"TeknikServisId").ToString() %>','Edit'); return false;" />   
     

Use the demo from the KB article linked below for additional reference:

http://www.telerik.com/support/kb/aspnet-ajax/grid/using-radwindow-for-editing-inserting-radgrid-records.aspx

Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Ceki Granti
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or