2016-08-03 11 views
-1

このコントローラのこのコントローラはエラーを表示しています。Sirグリッドビューのコードを実行していますが、エラーが表示されています

public class HomeController : Controller 
{ 
    [HttpGet] 
    public ActionResult Index() 
    { 
     ProductDetailModel obj = new ProductDetailModel(); 
     obj.ProductList = ProductData(""); 
     return View(obj); 
    } 

    [HttpPost] 
    public ActionResult SearchResult(string SearchKey) 
    { 
     ProductDetailModel obj = new ProductDetailModel(); 
     obj.ProductList = ProductData(SearchKey); 
     string strTable = ""; 
     strTable = strTable + "< table>< thead>< tr>< th>Id</ th ><th>Product_Name</ th >"; 
     strTable = strTable + "<th>Product_Detail</ th ><th>price</th></ tr></ thead>< tbody>"; 


     foreach (var item in obj.ProductList) 
     { 
      strTable = strTable + "<tr>"; 
      strTable = strTable + "<td>" + item.Id + "</ td >"; 
      strTable = strTable + "<td>" + item.Product_Name + "</ td >"; 
      strTable = strTable + "<td>" + item.Product_Detail + "</ td >"; 
      strTable = strTable + "< td>" + item.price + "</ td >"; 
      strTable = strTable + "</ tr >"; 
     } 
     strTable = strTable + "</ tbody ></ table >"; 
     return View(strTable); 
    } 

    public List<product> ProductData(string SearchKey) 
    { 
     List<product> objProduct = new List<product>(); 
     gridEntities objDemoEntities = new gridEntities(); 
     var productItem = from data in objDemoEntities.grids 
          where SearchKey == "" ? true : data.Product_Details.Contains(SearchKey) 
          select data; 

      foreach (var item in productData) 
      { 
       objProduct.Add(new product 
       { 
        Id = item.Id, 
        Product_Name = item.Product_Name, 
        Product_Detail = item.Product_Details, 
        price = (int)item.price 
       }); 
      } 
      return objProduct; 
     } 

卿これは エラー1 foreachのは、「メソッドのグループ」を操作することができないエラーです。あなたは 'メソッドグループ'を呼び出すつもりでしたか? C:¥Users¥andand.kumar¥Documents¥Visual Studio 2013¥Projects¥grid01¥grid01¥Controllers¥HomeController.cs 58 17 grid01 エラー2 'method group'が 'method group'型の変数を操作できません'GetEnumerator'のパブリック定義が含まれていないC:¥Users¥andand.kumar¥Documents¥Visual Studio 2013¥Projects¥grid01¥grid01¥Controllers¥HomeController.cs 58 17 grid01

+0

私はコントローラのコード全体を送信することができます –

+0

ほとんどの場合) ' –

+0

はそれではなく、単一のproductdata –

答えて

1

それぞれを以下のように変更します。

`ProductData`(そのメソッド、プロパティではないように見えます)あなたは` ProductData(必要
関連する問題