1

渡す必要のあるIDに基づいて画像を表示する部分ビューにモデルデータを送信するためのRazor構文を理解するのに問題があります。次のエラーメッセージが表示されます。

'System.Web.Helpers.WebGrid.Column(string、string、System.Func、string、bool)'に最適なオーバーロードされたメソッドの一致には、いくつかの無効な引数があります

メインビューからのコード:

@model IEnumerable<ProjectMVC.Models.Image_result>

@grid.GetHtml(tableStyle: "grid",
            headerStyle: "head",
            alternatingRowStyle: "alt",
            columns: grid.Columns
            (
                grid.Column(header: "Imageview", format: (item) => Html.Partial("ShowImage2", item))
            )
            );

Partial view:

@model ProjectMVC.Models.Image_result



@using System.Data.SqlClient;
@using System.Configuration;

@{
    ViewBag.Title = "ShowImage2";
}

@{
    var id = Model.id;
    if(id > 0)
    {
        string sqlText = "SELECT * FROM Images WHERE img_pk = " + id;
        SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);
        SqlCommand command = new SqlCommand(sqlText, connection);
        connection.Open();
        SqlDataReader dr = command.ExecuteReader();
        if (dr.Read())
            {
                Response.BinaryWrite((byte[])dr["img_data"]);
            }
            connection.Close();
    }
    }

どんな助けでもいただければ幸いです!

4

0 に答える 0