Select Row and Enter in a Server Side Code

6 posts, 0 answers
  1. lupotana
    lupotana avatar
    73 posts
    Member since:
    Nov 2006

    Posted 12 Oct 2009 Link to this post

    Hi, I've a small problem with RadGrid.
    I must transform old code with ASP.NET GridView in a new code with Telerik RadGrid.

    In old version I've two TemplateField in my GridView : in first column  there is a label with the code of row (hide) and in the second column there is an ImageButton with an Handler with the function btnUpdate_Click.

    ....

    <asp:TemplateField Visible="false">  
     <ItemTemplate> 
             <asp:Label ID="lblCode" runat="server" Text='<%# Bind("Code") %>' /> 
            </ItemTemplate> 
    </asp:TemplateField> 
    <asp:TemplateField> 
     <ItemTemplate> 
             <asp:ImageButton ID="btnEdit" runat="server"  ImageUrl="~/edit.png" OnClick="btnEdit_Click" CausesValidation="false" /> 
     </ItemTemplate> 
    </asp:TemplateField> 

    ......

    In function btnEdit_Click I cast the row and the Label control in the row and with the code I transfer the page.

    protected void btnEdit_Click(object sender, EventArgs e)  
    {  
     GridViewRow row = ((GridViewRow)((ImageButton)sender).NamingContainer);  
     Label lblCode = (Label)row.Cells[0].Controls[1];  
     Server.Transfer("~/Detail.aspx?Code="+lblCode.Text);  

    How do I do this operation with RadGrid?
    I don't want use the the Inline solution or client scripts.
    I need that when the user click on an imageButton or button in a row I enter in a server side code.

    Thanks,
    Marco

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Oct 2009 Link to this post

    Hello Marco,

    You can try out the following code to access the label in a TemplateColumn on clicking a button inside another TemplateColumn:
    c#:
     protected void btnEdit_Click(object sender, ImageClickEventArgs e) 
        { 
            GridDataItem row = ((GridDataItem)((ImageButton)sender).NamingContainer); 
            Label lblCode = (Label)row.FindControl("lblCode"); 
            Server.Transfer("~/Detail.aspx?Code=" + lblCode.Text);   
        } 

    Also go through the following help document which you may find helpful:
    Accessing cells and rows

    Thanks
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. lupotana
    lupotana avatar
    73 posts
    Member since:
    Nov 2006

    Posted 13 Oct 2009 Link to this post

    My problem is not the server code... the problem is that in RadGrid don't have a Template Column.
    How I manage an event click in an imagebutton in the row ?

    For example : a Row have an image for the update and an image for the delete.
    I don't want use the example of telerik..
    I want that after click the imagebutton I enter in a server code with the index row slected.

    Is possible ?
  5. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 16 Oct 2009 Link to this post

    Hi lupotana,

    RadGrid does have a template column and it is called GridTemplateColumn:
    http://www.telerik.com/help/aspnet-ajax/grdcolumntypes.html

    In addition, the solution Princy has offered is the valid one in your case.

    Greetings,
    Tsvetoslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. lupotana
    lupotana avatar
    73 posts
    Member since:
    Nov 2006

    Posted 05 Mar 2014 in reply to Tsvetoslav Link to this post

    Hi, with new versions of Telerik I able to do this operation.
    Now my question is : Server.Transfer work if I not use RadGrid with RadAjaxManager. Is not possible use Ajax with Server.Transfer ?


    protected void gvList_SelectedIndexChanged(object sender, EventArgs e)
     {
     GridItem row = gvList.SelectedItems[0];
     HttpContext.Current.Items.Add("Operation", EventContext.Update.ToString());
     HttpContext.Current.Items.Add("CustomerCode", row.Cells[2].Text);
     Server.Transfer("~/Desktop/Function/Customer/CustomerDetail.aspx");
    }

     
    sdsd
  7. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 10 Mar 2014 Link to this post

    Hello Marco,

    Basic server transfer couldn't be achieved during Ajax request. I would suggest you to revise the discussion below for more information on possible alternative approaches:
    http://stackoverflow.com/questions/9893433/ajax-enabled-update-progress-bar-on-server-transfer

    Regards,
    Maria Ilieva
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017