1

I am working on gridview and I am binding the data from code behind

Dim dataTblRep As New DataTable Dim dataRowRep As DataRowdataRowRep = dataTblRep.NewRow

dataRowRep("Batch Number") = "Totals : "
dataRowRep("Batch details") = "A" & <br/> & "B"

dataRowRep("Completed Docs") = TotEntryCount
dataRowRep("Received Docs") = TotSrcCount
dataTblRep.Rows.Add(dataRowRep)

gvRepOutput.DataSource = dataTblRep
gvRepOutput.DataBind()

So, in Batch details I am adding the two values from datatable and I want the "A" and "B" on seperate lines within the cell. But in the output I am getting "A <br/> B"

I have tried HtmlDecode but it is not working. Also, I am not using any Template Fields and I have the gridviews AutoGenerateColumns option set to True.

1 Answer 1

1

You need to use a Template column as BoundColumns HtmlEncode by default.

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

2 Comments

Thomas, I was hoping to avoid that. The code above is not my exact example. I am dynamically building the columns and the number of columns may vary. But, based on this, I may have to dynamically add templated columns to the grid view.
I turned auto generating off and dynamically added bound fields to the grid view based on the number of columns and set each bound fields htmlencode property to false and that did the trick for me. Thanks, Thomas!

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.