In the asp.net editable gridview I have header text as 'FieldName *'. As I am allowing user to enter the data and the data is mandatory.
Can I set FieldName with blue color and * with red color in header ?? If yes..how?
You can insert HTML code into the HeaderText for the FieldName.
Like this
HeaderText="<font color="blue">FieldName </font><font color="red">*</font>"
The page will interpret the HTML code and show it as you desire.
But you may have to set the HtmlEncode property for your BoundField in order to force the page to interpret the HTML code.
HtmlEncode="False"? Otherwise it won't render. As a side note, mark as accepted answers that work for you.You can make something out of this code.
Protected Sub gvName_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvIndexing.RowCreated
If e.Row.RowType = DataControlRowType.Header Then
Dim oGridView As GridView = CType(sender, GridView)
Dim oGridViewRow As GridViewRow = New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert)
Dim oTableCell As TableCell = New TableCell()
oTableCell.Text = "Header Value"
oTableCell.CssClass = "GridViewHeaderCSSClass"
oTableCell.ColumnSpan = 2
oGridViewRow.Cells.Add(oTableCell)
oGridView.Controls(0).Controls.AddAt(0, oGridViewRow)
Else
Dim oGridView As GridView = CType(sender, GridView)
oGridView.ShowHeader = False
End If
End Sub