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

[Solved] Command Button question

2 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin J
Top achievements
Rank 1
Kevin J asked on 03 Apr 2009, 07:31 PM
I have a grid with a command button on each row in the grid.

When a user clicks the button, it fires off the ItemCommand

Once I'm there, I don't know how to get values out of the columns or data that is behind the grid.  Can someone give me a quick example of how to do this please?  I tried looking through the help and various pages but I'm not sure what to search on for this. 

Thanks in advance
Kevin

2 Answers, 1 is accepted

Sort by
0
Accepted
Billy
Top achievements
Rank 1
answered on 03 Apr 2009, 07:45 PM
Hi Kevin,

I just figured this one out myself.  Here's the link that helped me: http://http//www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html

Basically, you have to cast the Item from the event args to a GridDataItem and then access the Cell.Text property of the cell you want.  Here's some basic code for c#
protected void Grid_ItemCommand(object source, GridCommandEventArgs e) 
    GridDataItem item = e.Item as GridDataItem; 
    TableCell myCell = item["myColumnName"]; 
    string myValue = myCell.Text; 

Hope that helps,

Billy
0
Kevin J
Top achievements
Rank 1
answered on 03 Apr 2009, 08:01 PM
Thanks Billy, that did the trick.  Here is how I did it in VB.NET

 

Dim itmITEM As Telerik.Web.UI.GridDataItem = CType(e.Item, Telerik.Web.UI.GridDataItem)

 

 

Dim cell As TableCell = itmITEM("TEMPID")

 

Response.Write(cell.Text)

Tags
Grid
Asked by
Kevin J
Top achievements
Rank 1
Answers by
Billy
Top achievements
Rank 1
Kevin J
Top achievements
Rank 1
Share this question
or