Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Grid > Access a conrol outside grid from ItemCommand

Answered Access a conrol outside grid from ItemCommand

Feed from this thread
  • rms avatar

    Posted on Apr 30, 2012 (permalink)

    Hi,

    my requirement is to show list of values in a grid and when the user clicks on one of the columns, I have to display a radbutton. this button is on the page and is outside the grid
    I am getting the commandname in the itemcommand event and trying to make radbutton visible.  button.visible=true. when i debug the code it looks like its working but the button is not diplayed. this button is invisible by default.
    do i have to do a find control like i do for the controls inside the grid? if so what is the syntax for it?

    Thanks.



    Reply

  • Posted on Apr 30, 2012 (permalink)

    Hello,

    Please check below code snippet.

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" >
     
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        <telerik:AjaxUpdatedControl ControlID="Button1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>

    let me know if any concern.

    Thanks,
    Jayesh Goyani

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.
  • rms avatar

    Posted on Apr 30, 2012 (permalink)

    That worked! thank you for a quick reply.

    Reply

  • rms avatar

    Posted on May 2, 2012 (permalink)

    I have another Issue now. I think this is also related to the above thats why I am posting in the same thread.

    I am trying to give a download functionality to the user on my page.

    Response.ClearContent()

    Response.ContentType =

     

    "application/vnd.xls"

     

    Response.AppendHeader(

     

    "Content-Disposition", "attachment; filename=" & OnlyName)

     

    Response.TransmitFile(filename)

    Response.End()

    the above code does not seem to work. this is on the same page where I have my Radgrid. What could be the work around for this?

    Thanks

    Reply

  • Answer Pavlina Pavlina admin's avatar

    Posted on May 7, 2012 (permalink)

    Hi,

    The help article below describes how to download files with Ajaxified controls:
    http://www.telerik.com/help/aspnet-ajax/ajax-download.html

    Kind regards,
    Pavlina
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.

    Reply

  • Posted on May 7, 2012 (permalink)

    Hello,

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <ClientEvents OnRequestStart="onRequestStart" />
             
        </telerik:RadAjaxManager>
    <script type="text/javascript">
            function onRequestStart(sender, args)
            {
                if (args.get_eventTarget().indexOf("lnkDownload") >= 0)
                {
                    args.set_enableAjax(false);
                }
            }
        </script>
    <MasterTableView DataKeyNames="ID" >
                    <Columns>
                         
                        <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
                        </telerik:GridBoundColumn>
                         
                        <telerik:GridTemplateColumn>
                            <ItemTemplate>
                                <asp:LinkButton ID="lnkDownload" runat="server" Text="Download sample excel file"
                                    OnClick="lnkDownload_Click" CausesValidation="false"></asp:LinkButton>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
    protected void lnkDownload_Click(object sender, EventArgs e)
            {
                // you can access your grid row
                Button lnkDownload = sender as Button;
                GridDataItem item = lnkDownload.NamingContainer as GridDataItem;
                string str1 = item.GetDataKeyValue("ID").ToString(); // by datakey ID
                string str2 = item["ID"].Text; // by column name
                try
                {
     
                    string path = Server.MapPath("~/filepath/YourFilename.xlsx");
                    string attachment = "attachment; filename=yourfilename.xlsx";
                    Response.Clear();
                    Response.AddHeader("content-disposition", attachment);
                    Response.ContentType = "text/plain";
                    Response.WriteFile(path);
                    Response.End();
                }
                catch (Exception ex)
                {
                     
                }
            }


    Thanks,
    Jayesh Goyani

    Reply

  • rms avatar

    Posted on May 8, 2012 (permalink)

    Both the solutions worked. Thank you Jayesh and Pavlina.

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Grid > Access a conrol outside grid from ItemCommand
Related resources for "Access a conrol outside grid from ItemCommand"

ASP.NET Grid Features  |  Documentation  |  Demos  |  Step-by-step Tutorial  ]