This is a migrated thread and some comments may be shown as answers.

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

3 Answers 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mario
Top achievements
Rank 2
Mario asked on 24 Jun 2009, 03:05 PM
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

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 29 Jun 2009, 08:22 AM
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.
0
Mario
Top achievements
Rank 2
answered on 29 Jun 2009, 10:10 AM
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?
0
Yavor
Telerik team
answered on 02 Jul 2009, 06:06 AM
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.
Tags
Grid
Asked by
Mario
Top achievements
Rank 2
Answers by
Yavor
Telerik team
Mario
Top achievements
Rank 2
Share this question
or