简体   繁体   中英

Get column names for each updated items in Radgrid

I'm using C# 4 and ASP.Net. I'm using Telerik at version 2012.1.228.40.

I generate dynamically column names while building my datasource and I would like to get this column name back when the user updates a row.

protected void radGridTranslation_ItemCommand(object _sender, GridCommandEventArgs _event)
{
    if (_event.Item is GridDataItem)
    {
        GridDataItem l_dataItem = (GridDataItem)_event.Item;
        string l_sColumnName = ... ? ...
    }
}

Edit (after hutchonoid post) : I don't want to know the column names in my code behind. They need to be dynamically built from a database query. Therefore, I cannot use properties such as UniqueName .

Any idea how I would do that ?

Here is something that worked :

protected void radGridTranslation_ItemCommand(object _sender, GridCommandEventArgs _event)
{
    if (_event.Item is GridDataItem)
    {
        if (_event.CommandName == myRadGrid.UpdateCommandName)
        {
            GridDataItem l_dataItem = (GridDataItem)_event.Item;
            Dictionary<string, string> l_gridUpdatedItemList = new Dictionary<string, string>();
            l_dataItem.ExtractValues(l_gridUpdatedItemList);

            foreach (KeyValuePair<string, string> l_updatedItemWithColumn in l_gridUpdatedItemList)
            {
                // Key = The column name
                // Value = The cell value
            }
        }
    }
}

Hope it will help someone else !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM