retrieving value of the entity of the column a button clicked event fired

4 posts, 0 answers
  1. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 24 Jun 2009 Link to this post

    Hi,

    i have my radgrid and i put in there a RadGridColumn Type ImageButton. I handle its fired Event in code behind with following method:

    private void GridCommand(object o, Telerik.Web.UI.GridCommandEventArgs e) 
                if (e.CommandName == "Delete") 
                { 
                    try 
                    { 
                        int rowNr = e.Item.ItemIndex; 
     
                        int startSS = radGrid.Items[rowNr].KeyValues.IndexOf("\"") + 1; 
                        int endSS = radGrid.Items[rowNr].KeyValues.IndexOf("\"", startSS); 
                        int id = Convert.ToInt32(radGrid.Items[rowNr].KeyValues.Substring(startSS, endSS - startSS)); 
     
                        string filepath = BLDocument.DeleteDocument(id); 
                         
                        if(File.Exists(filepath)) 
                            File.Delete(filepath); 
     
                        BindTo(); 
                    } 
                    catch (Exception ex) 
                    { 
     
                    } 
                } 

    That way i retrieve the id, delete the entity in my database and rebind the DataSource to the radgrid so it updates its state to the new database state.

    Questions:

    The radGrid.Items[rowNr].KeyValues give me this back "{id:\"3\"}". Is the so cause i gave the radgrid this property:
                                                   <MasterTableView DataKeyNames="id">   ?

    How would i be able to do it in another way retrieving this id?
    I also have there a Invisible GridBoundColumn also holding the id. How would i be able to get that id?
    Is there another way to actualize the radgrid (accept of my way or Rebind() which didnt work)?

    Another attached handler method in the back wants to let the client download the chosen document, but i get following exception:

    [System.Threading.ThreadAbortException] = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}

    I set EnablePostBackOnRowClick="true" but it didnt change anything. Is there a away to get that exception lost?





    thx mario
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 29 Jun 2009 Link to this post

    Hello Mario,

    The following article contains additional information on how to reference any cell, not just the key values.
    I hope this information helps.

    Greetings,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 29 Jun 2009 Link to this post

    Another attached handler method in the back wants to let the client download the chosen document, but i get following exception:

    [System.Threading.ThreadAbortException] = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}

    What can i do against that. I know that i am able to walkaround that problem by Response.Redirect("url", false). But i want to do the filedownload in the same window not in another which maybe is the only possibility?
  5. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 02 Jul 2009 Link to this post

    Hi Mario,

    Based on the supplied information, it is hard to determine what is causing the unwanted behavior. If the issue persists, you can open a formal support ticket, and send us the problematic code, for additional testing.

    Greetings,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top