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

GridBound Column value in ItemCommand Event

1 Answer 298 Views
Grid
This is a migrated thread and some comments may be shown as answers.
kunal patel
Top achievements
Rank 1
kunal patel asked on 29 Jan 2010, 01:21 PM
Hello,
           I have used radgrid on my page.
           I have four GridBoundColumn which are bound with database column field.

           e.g>.
                   <telerik:GridBoundColumn DataField="Col1" HeaderText="Col1" ReadOnly="True" SortExpression="Col1"
                                            UniqueName="Col1">
                   </telerik:GridBoundColumn>
           Now, i want to retrive this GridBoundColumn values i.e Col1 Value  in Grid's ItemCommand Event
           i.e.,
                    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
                    {
                             // Col1 Value
                    }
          

    Please reply me as soon as possible

Thanks & Regards,
Kunal Patel    


                           

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 29 Jan 2010, 01:26 PM
Hello kunal,

 Just add col1 to the DataKeyNames collection of the MasterTableView and in the ItemCommand event get the column's value as follows:

if (e.Item is GridDataItem)
{
    string col1Value = ((GridDataItem)e.Item).GetDataKeyValue("col1").ToString();
 
}

I hope this helps.

Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
kunal patel
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or