0

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Are you sure you set the HtmlEncode to false? Like this HtmlEncode="False"? Otherwise it won't render. As a side note, mark as accepted answers that work for you.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.