RadGrid, TemplateColumn and ImageButton

14 posts, 0 answers
  1. Mattia
    Mattia avatar
    11 posts
    Member since:
    Jun 2011

    Posted 30 Jun 2011 Link to this post

    Hi all,
    I have a Rad grid with a column template like the following:

    <telerik:GridTemplateColumn HeaderText="Actions" UniqueName="Actions">
     <ItemTemplate>
     <div class="sfBasicLangs">
      <asp:ImageButton runat="server" CommandName="delete" OnCommand="Delete" />
     </div>
    </ItemTemplate>
    </telerik:GridTemplateColumn>

    the Delete method present in the OnCommand is never fired.... how can  have radGrid fire it.
    I've already tried to enable viewstate on the grid

    Thanks,
    Mattia
  2. Mattia
    Mattia avatar
    11 posts
    Member since:
    Jun 2011

    Posted 01 Jul 2011 Link to this post

    Someone...
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 01 Jul 2011 Link to this post

    Hi,

    method 1 :

    <
    asp:ImageButton runat="server" CommandName="Userdelete"
    >

    ItemCommand()
    {
        if(e.CommandName == "Userdelete")
        {
          // write your logic here
         }
    }

    method 2 :

    <
    asp:ImageButton runat="server" CommandName="Delete"
    >

    Deletecommand()
    {
       // wrote your logic here
    }

    Thanks,
    Jayesh Goyani
  5. Mattia
    Mattia avatar
    11 posts
    Member since:
    Jun 2011

    Posted 01 Jul 2011 Link to this post

    Hi Jayesh,
    thanks for the answer but I have already implemented the Delete function... The problem is that the function is never fired.

    Thanks,
    Mattia
  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 01 Jul 2011 Link to this post

    Hello Mattia,
    I was unable to recreate the issue at my end. Please make sure that you have attached the event correctly. Here am pasting the full code.
    aspx:
    <telerik:RadGrid AllowAutomaticUpdates="true" ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1"
       AllowPaging="True" CellSpacing="0" GridLines="None" OnItemCommand="RadGrid1_ItemCommand">
      <MasterTableView DataKeyNames="OrderID" PageSize="10" AllowFilteringByColumn="true" CommandItemDisplay="Top" AutoGenerateColumns="False" EditMode="InPlace">
        <columns>
          <telerik:GridBoundColumn DataField="ShipCountry" FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry" SortExpression="ShipCountry" UniqueName="ShipCountry">
          </telerik:GridBoundColumn>
          <telerik:GridTemplateColumn HeaderText="Actions" UniqueName="Actions">
             <ItemTemplate>
               <asp:ImageButton ID="ImageButton1" runat="server" CommandName="delete" OnCommand="Delete" />
             </ItemTemplate>
          </telerik:GridTemplateColumn>               
         </Columns>             
     </MasterTableView>      
     </telerik:RadGrid>

    C#:
    protected void Delete(object sender, CommandEventArgs e)
       {
       }
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
       {
       }

    Thanks,
    Princy.
  7. Mattia
    Mattia avatar
    11 posts
    Member since:
    Jun 2011

    Posted 01 Jul 2011 Link to this post

    Hi,
    i found the problem. The command is fired only if I do the databinding in the Page_Load.
    The problem is that I need to have the value of a dropdown to filter the datasource and, as far as the Page_Load event if fired before the controls event I always get the old value.
    If I can only bind the grid in the page load how I can I accomplish this?

    Thanks,
    Mattia
  8. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 05 Jul 2011 Link to this post

    Hello Mattia,

    Please examine this help topic to see how the desired functionality can be implemented.

    I hope it helps.

    Kind regards,
    Mira
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  9. Mattia
    Mattia avatar
    11 posts
    Member since:
    Jun 2011

    Posted 05 Jul 2011 Link to this post

    Thanks Mira,
    I solved my problem by binding the grid with a objectDataSource instead of manually doing it in dropdown onSelectedIndexChanged event.
    But I still don't understand why if I do it manually in the onSelectedIndexChanged event the commands are not fired. 

    Thanks,
    Mattia
  10. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 05 Jul 2011 Link to this post

    Hello Mattia,

    In order the RadGrid to work correct, you should data-bind it properly.
    Please examine the Telerik RadGrid data binding basics help topic and the Data-binding help section for additional information.

    I hope this helps.

    All the best,
    Mira
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  11. bharath
    bharath avatar
    23 posts
    Member since:
    Jun 2011

    Posted 11 Mar 2015 in reply to Jayesh Goyani Link to this post

    Hi Jayesh Goyani,

     i have asp:imageButton in radgrid templete column.When i click on the imagebutton i am getting javascript runtime error "unable to get the property 'style' of undefined or null reference. this is comming only on IE.when i run the page in crome script  error is not coming.i added style property to image button.

     With Regards
     Bharath.
  12. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 11 Mar 2015 in reply to bharath Link to this post

    Hello,

    If I am not wrong than this is the IE version specific issue. Please make sure you used latest telerik version.

    If you are not able to resolved this issue than please provide your code snippet.

    The error was thrown from dadgrid's in-built js file. So, if we add the external style than also it will not resolved your existing issue.

    Let me know if any concern.

    Thanks,
    Jayesh Goyani
  13. bharath
    bharath avatar
    23 posts
    Member since:
    Jun 2011

    Posted 11 Mar 2015 in reply to Jayesh Goyani Link to this post

    Hi Jayesh,

     My radgrid inside the update panel.When i removed update panel i am not getting the script error.

    With Regards
    Bharath
  14. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 12 Mar 2015 in reply to bharath Link to this post

    Hello,

    As per my knowledge there are multiple reason for this.
    So could you please provide your grid code including update panel?

    Thanks,
    Jayesh Goyani
  15. bharath
    bharath avatar
    23 posts
    Member since:
    Jun 2011

    Posted 09 Apr 2015 in reply to Jayesh Goyani Link to this post

    HI Jayesh Goyani,

             i need to create dynamic radgrid with DropdownBox and checkBox . After getting the datasourse i need to check values of corresponding columns and need to do check or uncheck and selected item for dropdown.

      After pageload with the above i need to change the dropdownbox values and checkbox chek or uncheck.

      after i have to saved the latest values of radgrid by Button click event which is out side of grid.

       can you guide on this and create a sample page.

     

    /Bharath

     

     

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