Passing parent control values to RadWindow from Grid Click

4 posts, 0 answers
  1. Shawn
    Shawn avatar
    83 posts
    Member since:
    Jan 2009

    Posted 29 Jun 2009 Link to this post

    I am currently launching a RadWindow from my grid when I click a row like so:
    GRID:
    <ClientSettings AllowDragToGroup="True" EnablePostBackOnRowClick="False"  
                EnableRowHoverStyle="True" ClientEvents-OnRowClick="RowClick"
                <ClientEvents OnRowClick="RowClick" /> 
            </ClientSettings> 

    function RowClick(sender, eventArgs) { 
                        window.radopen("report_details.aspx?zipcode=" + eventArgs.getDataKeyValue("ZIPCode"), "UserListDialog"); 
                    } 

    But I also need to pass 3 other values from my page that are not part of the grid, two dates from RadDatePicker controls and a Numeric Textbox.  I tried to get them from the RadWindow page load like so:
    Dim obj_startDate As RadDatePicker = Parent.FindControl("txt_start_date"
            Dim obj_endDate As RadDatePicker = Parent.FindControl("txt_end_date"
            Dim obj_Radius As RadNumericTextBox = Parent.FindControl("txt_Radius"
     
    Dim startDate As Date = obj_startDate.SelectedDate 
            Dim endDate As Date = obj_endDate.SelectedDate 
            Dim Radius As Decimal = obj_Radius.Text 

    But that doesn't work....  What am I missing here?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 30 Jun 2009 Link to this post

    Hi Shawn,

    You can also pass the values of RadDatePicker and RadNumericTextBox as Url parameter when opening the window.

    JavaScript:
     
    function OnRowClick(sender, eventArgs)  
    {  
         var RadDatePicker1 = $find('<%= RadDatePicker1.ClientID %>');   
         var date = RadDatePicker1.get_selectedDate();      
         var input = $find('<%= RadNumericTextBox1.ClientID %>');    
         var value = input.get_value();     
         var zipCode= eventArgs.get_gridDataItem().getDataKeyValue("zipcode");  
         var oWnd = radopen("report_details.aspx?zipCode=" + zipCode+"&date="+ date +"&value=" + value, "RadWindow1");  
         oWnd.Center();  

    The parameters that you send can be read from the Request object in the Page_Load method of the RadWindow page.

    C# code for report_details.aspx:
     
    protected void Page_Load(object sender, EventArgs e)  
    {  
        if (Request["zipCode"] != null && Request["date"] != null && Request["value"] != null)  
        {  
            Response.Write(Request["zipCode"]);  
            Response.Write(Request["date"]);  
            Response.Write(Request["value"]);  
        }  

    Thanks,
    Princy.
  3. Peter Ivanov
    Peter Ivanov avatar
    6 posts
    Member since:
    Oct 2009

    Posted 28 Nov 2009 Link to this post

    Hi,

    I'm pretty new to web development and even more so to the .Net tools and controls. I'm currently working on a gridview with an edit button, this button has to open a radwindow and send 2 values to the window via a query string. How can I do this using VB.Net?

    Thanks,

    Peter.
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Nov 2009 Link to this post

    Hi Peter,

    Have you seen the online demo which shows how to use RadWindow for editing RadGrid records. You can pass the required values to the ShowEditForm function when adding the 'onclick' attribute to button from code. And then pass these values to the RadWindow as shown below when opening the window.

    jscript:
     
    function ShowEditForm(value1, ,value2 ,rowIndex) // First two parameters are passsed from code when adding the onclick attribute 
          var grid = $find("<%= RadGrid1.ClientID %>");                 
          var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element(); 
          grid.get_masterTableView().selectItem(rowControl, true); 
                             
          window.radopen("EditForm.aspx?FirstValue=" + value1+"&SecondValue="+value2, "UserListDialog"); 
     
          return false

    -Shinu.
Back to Top