1

I want HeaderText to be displayed only when Edit Mode is active

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

I don't have Insert Template And I want header text to be displayed in only during edit mode

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
levi
  • 3,451
  • 6
  • 50
  • 86
  • **Blake** Your Code snippet helped me it changes successfully when I click Edit, but when I click Edit once more `grd.HeaderRow.Cells[0].Text` becomes default again as `(e.Row.RowState == DataControlRowState.Edit)` returns false – levi Sep 27 '11 at 07:02

1 Answers1

1

One way to do so would be to subscribe to the RowDataBound (assuming you are using a GridView). Check if a Row is in the Edit state, and update the corresponding header text for the Cell.

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.
    }
}
Doozer Blake
  • 7,677
  • 2
  • 29
  • 40