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

rebind grid by clicking a button on the radwindow

15 Answers 250 Views
Window
This is a migrated thread and some comments may be shown as answers.
Priya
Top achievements
Rank 1
Priya asked on 22 Sep 2008, 12:08 PM
Sir

I have a Page, say Page1.aspx.In it a radGrid and link button is placed
When I click on the linkbutton, a radwindow with a usercontrol is loaded.
ie,

in Page1.aspx

function

openRadWindowCustomSearch()

{

var oWnd = radopen("Custom_Search_Page.aspx", "RadWindow2" );

oWnd.setSize(700,550)

oWnd.center();

}

Inside Custom_Search_Page.aspx ,I placed a usercontrol ie,
in
 Custom_Search_Page.aspx

<

form id="form1" runat="server">

<div>

<uc1:CustomSearch id="uclCustomSearch" runat="server" />

</div>

</form>


That usercontrol contains a button
While clicking on tht button I want to rabind the grid in Page1

Thanks in advance

15 Answers, 1 is accepted

Sort by
0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 22 Sep 2008, 02:34 PM

You can click with a javascript over the button which rebinds the RadGrid,e.g.
 
PAGE1.ASPX

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>Untitled Page</title> 
      
</head> 
<body> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
    <div> 
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">  
            <Windows> 
                <telerik:RadWindow ID="RadWindow1" runat="server" NavigateUrl="ContentPage.aspx" 
                VisibleOnPageLoad="true" 
                ></telerik:RadWindow> 
            </Windows>          
        </telerik:RadWindowManager> 
        <asp:Button ID="btnRebindGrid" runat="server" Text="RebindGrid" style="display:none" /> 
        <telerik:RadGrid ID="RadGrid1" runat="server"></telerik:RadGrid> 
         </div> 
    </form> 
</body> 
</html> 

PAGE1.ASPX.CS

   protected void Page_Load(object sender, EventArgs e)  
    {  
        string[] newData = {"a","b","c" + System.DateTime.Now.ToString()};  
        RadGrid1.DataSource = newData;  
        RadGrid1.DataBind();  
    } 

CONTENTPAGE.ASPX

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server">  
    <title>Untitled Page</title> 
    <script type="text/javascript">  
        function RebindGrid()  
        {  
            var parentWindow = window.parent;  
            parentWindow.$get("btnRebindGrid").click();  
              
        }  
    </script> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <div> 
    <input type="button" id="myControl" value="RebindGrid" onclick="RebindGrid()" /> 
    </div> 
    </form> 
</body> 
</html> 

Hope this helps!

0
Priya
Top achievements
Rank 1
answered on 23 Sep 2008, 04:44 AM

Sir
But the content page is a usercontrol and this usercontrol is placed in another aspx file ie,Custom_Search_Page.aspx
So
when i use
var parentWindow = window.parent;

I wil get only Custom_Search_Page.aspx

And the grid is on Page1.aspx

0
Georgi Tunev
Telerik team
answered on 23 Sep 2008, 11:33 AM
Hi Priya,

You can try with
top.$get("btnRebindGrid").click(); 
this way you will get a reference to the topmost page which in your scenario is the page from which you have called RadWindow and where the grid is.



Regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Priya
Top achievements
Rank 1
answered on 24 Sep 2008, 04:39 AM
Sir,

I m gettg the javascript error
'top.$get(..)is null or not an object when i write it in code behind of usercontrol
ie,
Usercontrol.ascx.vb

Protected

Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click

Dim ds As New DataSet()

ds = Custom_SearchBAL.GridDataSource

Dim strFilterExp As String

Dim i As Integer

For i = 0 To ds.Tables(0).Rows.Count - 1

Custom_SearchBAL.SelectedFieldDatatype = ds.Tables(0).Rows(i)(

"Datatype")

strFilterExp = strFilterExp + ds.Tables(0).Rows(i)(

"ANDOR") + ds.Tables(0).Rows(i)("FilterExp")

Next

Custom_SearchBAL.ResultantFilterExp = strFilterExp

Dim strScript As String

strScript =

"<script language=javascript>"

strScript +=

"top.$get('btnRebindGrid').click();"

strScript +=

"<"

strScript +=

"/script>"

Page.RegisterStartupScript(

"MSGE", strScript)

Page1.aspx

<asp:Button ID="btnRebindGrid" runat="server" Text="RebindGrid" style="display:none" />

Page1.aspx.vb

Protected Sub btnRebindGrid_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRebindGrid.Click

WorkDetailsGrid.Rebind()

End Sub



0
Priya
Top achievements
Rank 1
answered on 24 Sep 2008, 06:38 AM
help me plz..
0
Georgi Tunev
Telerik team
answered on 24 Sep 2008, 08:44 AM
Hi Priya,

This thread is getting quite long and since we are still unable to provide you with solution, I would like to ask you to open a support ticket and to send us a full, working project where the problem can be reproduced. We will check it and get back to you with a solution.


All the best,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Priya
Top achievements
Rank 1
answered on 24 Sep 2008, 11:04 AM
Sir,

I created a simple project and applied ur code ther and is working fine
So I thk my prj's prbm is due postback or any other operatn on the ascx.Is ther any possibility for tht.
I m really confused
Thanks alot for ur reply
0
Georgi Tunev
Telerik team
answered on 25 Sep 2008, 05:58 AM
Hi Priya,

I don't see how a user control would affect that behavior, but unfortunately without a reproduction sample, I cannot tell what the problem is. If you manage to isolate the problem, please send it to me and I will check it right away.



Kind regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Priya
Top achievements
Rank 1
answered on 25 Sep 2008, 06:27 AM
Sir,
The page1.aspx is a contentpage ie,masterpage is included in my prj.Is ther is a chance for my error due to it
0
Priya
Top achievements
Rank 1
answered on 25 Sep 2008, 06:31 AM
Sir,
its the prbm .Any way to solve it
0
Priya
Top achievements
Rank 1
answered on 25 Sep 2008, 07:07 AM
plz help me..
0
ayh
Top achievements
Rank 1
answered on 18 Nov 2008, 12:15 PM
hi priya
i have same problem like you, i think you are closer than me solving the problem, my mail ayhantay@yahoo.com would you send me your code about the problem plz?
0
Svetlina Anati
Telerik team
answered on 18 Nov 2008, 01:04 PM
Hi guys,

I assume that most probably the problem comes from the fact that both the MasterPage and the User Control are INaming Containers - this means that they change the IDs of the controls they contain. This is general ASP.NET knowledge and you can reproduce the issue by using a standard control, e.g asp button instead of RadControl - you will get the same behavior and the button will not be found. However, if you cannot manage to solve the problem yourself, prepare a sample, fully runnable demo (with DB, if needed, e.g use Northwind), open a new support ticket and send it us along with detailed reproduction steps and explanations of the actual and the desired behavior. 

Best wishes,
Svetlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
mac
Top achievements
Rank 1
answered on 19 Nov 2008, 07:46 PM
good day. I am attempting to match very closely the scenario indicated here as well with a few twists. I have the following application working 'slightly' with a master page as well.
  • The master page is just a blank master page with a contentplaceholder. 
    (Priya  - Check your source code of the rendered name of the button and get that)
Some strange thngs happen when I run this in FF vs. IE. in ff the window will not close.
  • in IE and FF it will close and update the grid the first time... after that it craps out.
  • having the grid or button nested in ajaxpanel does not make a difference with either browser.

I am hoping somone could allude to :

  1. Why the js craps out after pressing the contentpage button
  2. How I would get a server event to run when clicking serverbtn on clientpage. and then close radwindw, update relevant grid

Page1.aspx

<asp:ScriptManager ID="sm1" runat="server" /> 
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"   
Height="200px" width="300px">  
    <asp:Button id="GridButton" runat="server" Text="GridButton" />          <br /> 
             <uc1:gridpage ID="Gridpage1" runat="server" /> 
         </telerik:RadAjaxPanel> 
          
         

Page1.vb

Protected Sub GridButton_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles GridButton.Click  
        Gridpage1.DataBind()  
    End Sub 

Gridpage.ascx

<telerik:RadWindowManager Width="100px" Height="100px" ID="RadWindowManager1" runat="server"    Behavior="Default" InitialBehavior="None" Left="" Top="">  
    </telerik:RadWindowManager> 
<script type="text/javascript">  
    function openRadWindow(ApplicationID)  
        {  
            var oWnd = window.radopen("contentpage.aspx?ApplicationID=" +ApplicationID, "RadWindow2" );  
                   oWnd.center();   
        }  
</script> 
<telerik:RadGrid ID="RadGrid1" runat="server">  
    <MasterTableView> 
        <Columns> 
            <telerik:GridTemplateColumn> 
                <ItemTemplate> 
                    <href="#" onclick="openRadWindow('<%# Container.DataItem %>'); return false;">Cancel</a> 
                </ItemTemplate> 
            </telerik:GridTemplateColumn> 
        </Columns> 
    </MasterTableView> 
</telerik:RadGrid> 

Gridpage.vb

Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
        Dim str As String() = {"a""b""c"Date.Now.ToString()}  
        RadGrid1.DataSource = str  
        RadGrid1.Rebind()  
    End Sub 

contentpage.aspx

  <script type="text/javascript">     
       
        function RebindGrid()     
        {     
            var parentWindow = window.parent;     
            parentWindow.$get("ctl00_ContentPlaceHolder1_GridButton").click();  
        }   
               
    </script>    
    <asp:Button ID="btn" runat="server" Text="serverbtn" OnClientClick="RebindGrid();" /> 
     

ContentPage.vb

Protected Sub btn_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles btn.Click  
        'Run Some code.. but it won't because the page keeps closing before the event  
        createcancel()  
 
    End Sub 

thank you very much for any assistance.
mac
0
Svetlina Anati
Telerik team
answered on 24 Nov 2008, 01:33 PM

Hi Mac,

I am afraid that the scenario is too complex to completely understand it only based on separate pieces of code. However we have an online demo which is very similar to your scenario - you can find it here.  When you install RadControls, our online examples projects are automatically installed on your computer and you can not only examine their full source code, but also extend them further in order to meet your requirements.

You can open the demos from here:

Start\Programs\Telerik\RadControls for ASPNET AJAX\Open Sample WebSite In VisualStudio

The actual location on your hard disk is the following one:

C:\Program Files\Telerik\RadControls for ASPNET AJAX \Live Demos

In case examining the full source does not help, please open a new support ticket and send me a sample, fully runnable reproduction demo (including DB or fake datasource, e.g. XML file, if needed) along with detailed reproduction instructions and explanation of the desired behavior. Once I receiev it, I will do my best to modify it in porder to meet your requirements.



All the best,

Svetlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Window
Asked by
Priya
Top achievements
Rank 1
Answers by
Obi-Wan Kenobi
Top achievements
Rank 1
Priya
Top achievements
Rank 1
Georgi Tunev
Telerik team
ayh
Top achievements
Rank 1
Svetlina Anati
Telerik team
mac
Top achievements
Rank 1
Share this question
or