0

テキストの代わりに画像を表示するように列の 1 つを変更しようとしています。現在、テキストはすべて SQL から収集されています。

            if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRow dr = ((DataRowView)e.Row.DataItem).Row;

            HyperLink EditLink = (HyperLink)e.Row.FindControl("EditLink");
            EditLink.NavigateUrl = "javascript:ShowDialogTest('2','" + dr[0].ToString() + "')";
            HyperLink DeleteLink = (HyperLink)e.Row.FindControl("DeleteLink");
            DeleteLink.NavigateUrl = "javascript:ShowDialogTest('3','" + dr[0].ToString() + "')";

            System.Web.UI.WebControls.Image i = (System.Web.UI.WebControls.Image)e.Row.FindControl("Overall Status");
            i.ImageUrl = "url";

        }

したがって、EditLink と DeleteLink は ASP にあり、これらは機能します。[Overall Status] は SQL の 1 つのフィールドであり、画像に変更できません。

まだデータがバインドされていないため、そのフィールドが見つからない可能性があると思いましたが、FindControls の数を表示しました = SQL の結果 + 2 つのフィールド。

次に、私の ..FindControl(THISNAME) が間違っているのではないかと思いました。ただし、コントロールの名前を見つける方法がわかりません。e.Row.Controls[index].Name (私はインデックスを知っています) のようなものでなければなりませんが、どの属性を取るべきかわかりません。

ありがとう、

4

1 に答える 1

1

This is usually done in the RowCreated method of the GridView (or at least I do it this way), as fas as i know on the RowDataBound you only have the data for the row but it doesn't exist on the page yet, to find a control in a row use e.Row.Cells[X].FindControl("ControlName")

Hope this helps...

于 2012-08-17T02:22:24.197 に答える