1

編集モードが有効なときだけ HeaderText を表示したい

   <asp:TemplateField>
     <EditItemTemplate>
         <asp:FileUpload ID="fileUploadControl" runat="server" />
     </EditItemTemplate>
   </asp:TemplateField>

挿入テンプレートを持っていません。また、ヘッダー テキストを編集モード中にのみ表示したいです。

4

1 に答える 1

1

これを行う1つの方法は、RowDataBoundをサブスクライブすることです(GridViewを使用していると仮定します)。行が編集状態にあるかどうかを確認し、セルに対応するヘッダーテキストを更新します。

protected void grd_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowState == DataControlRowState.Edit)
    {
        grd.HeaderRow.Cells[0].Text = "Upload a File"; // Cell 0 in this case may need to be changed to match your Cell.
    }
}
于 2011-09-26T16:15:56.320 に答える