从List <object> </object>获取值

时间:2014-04-03 22:22:15

标签: c#

我需要从列表中获取单个值并将其作为参数传递

List<object> selectedValues;
private void GetSelectedValues() 
{

    ASPxGridView grid = (ASPxGridView)StoreDropDown.FindControl("StoreGV");
    List<string> fieldNames = new List<string>();
    foreach (GridViewColumn column in grid.Columns)
        if(column is GridViewDataColumn)
            fieldNames.Add(((GridViewDataColumn)column).FieldName);
    selectedValues = grid.GetSelectedFieldValues(fieldNames.ToArray());

}

这是我的方法的一部分

store = Store.SelectOne(270);//Here is where I want to get value from GetSelectedValues
                             //Insted of 270 I want the vaue from GetSelectedValues  

if (e.Date < leadDay || e.Date > OrderDOW.OrderOutDate ||!store.IsAvailable(e.Date))
{


    e.Cell.Attributes["disabled"] = "disable";
    e.Cell.Attributes["style"] = "pointer-events: none; background-color: red";

}

1 个答案:

答案 0 :(得分:0)

我理解你的问题,你可以使用foreach为每个列表元素做任何你想做的事情

foreach(String fieldName in fieldNames)
{
    store = Store.SelectOne(fieldName);

    if (e.Date < leadDay || e.Date > OrderDOW.OrderOutDate ||!store.IsAvailable(e.Date))
    {
        e.Cell.Attributes["disabled"] = "disable";
        e.Cell.Attributes["style"] = "pointer-events: none; background-color: red";

    }
}