delete in radgrid without using sqldatasource

6 posts, 0 answers
  1. Coolbudy
    Coolbudy avatar
    24 posts
    Member since:
    Nov 2012

    Posted 27 Nov 2012 Link to this post

    hey friends,


        i want to delete in radgrid without using sqldatasource i telerik gridtemplatecolumn
     <telerik:GridTemplateColumn UniqueName="TemlateDeletecolumn" AllowFiltering="false">
                                <ItemTemplate>
                                <asp:HyperLink ID="DeleteLink" runat="server"  ImageUrl="Delete.gif"></asp:HyperLink>
                                </ItemTemplate>
                                
                                </telerik:GridTemplateColumn>

    how can i do this?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Nov 2012 Link to this post

    Hi,

    I guess you want to do delete without using automatic crud operation. One suggestion is to use a ImageButton instead of the hyperlink and add CommandName as delete.

    ASPX:
    <telerik:GridTemplateColumn>
        <ItemTemplate>
            <asp:ImageButton ID="DeleteLink" runat="server" CommandName="Delete" Text="delete" ImageUrl="Delete.gif" />
        </ItemTemplate>
    </telerik:GridTemplateColumn>

    C#:
    protected void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e)
    {
      //your code to delete
     
    }

    Thanks,
    Princy.
  3. Coolbudy
    Coolbudy avatar
    24 posts
    Member since:
    Nov 2012

    Posted 27 Nov 2012 Link to this post

     protected void RadGrid1_ItemDeleted(object sender, GridDeletedEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                HyperLink DeleteLink = (HyperLink)e.Item.FindControl("DeleteLink");
                GridDataItem dataItem = (GridDataItem)e.Item;
                String id = dataItem.GetDataKeyValue("Uid").ToString();
                objRes = objTest.DeleteRegisterTk(Convert.ToInt32(id));
            }  
            
        }
  4. Coolbudy
    Coolbudy avatar
    24 posts
    Member since:
    Nov 2012

    Posted 27 Nov 2012 Link to this post

    i don't got any result
  5. Coolbudy
    Coolbudy avatar
    24 posts
    Member since:
    Nov 2012

    Posted 27 Nov 2012 Link to this post

    I write this but not deleted

    protected void RadGrid1_ItemDeleted(object sender, GridDeletedEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                HyperLink DeleteLink = (HyperLink)e.Item.FindControl("DeleteLink");
                GridDataItem dataItem = (GridDataItem)e.Item;
                String id = dataItem.GetDataKeyValue("Uid").ToString();
                objRes = objTest.DeleteRegisterTk(Convert.ToInt32(id));
            }  
            
        }
  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Nov 2012 Link to this post

    Hi,

    ItemDeleted is fired when an automatic delete operation is executed. I guess you are trying to delete a row on clicking the hyperlink. In-order to perform delete operation, try the method I have mentioned above.

    Thanks,
    Princy.
Back to Top