Gridview - disappearing data when column is hidden

S

steve.falzon@

Hi Folks

I've hit a problem that is givng me a real headache. I've been at this
for hours, I need some sleep :)

In the RowDatabound event I'm building a string which uses a value of
a visible column. When all the rows have been added I hide the column
and this is where the dificulties start.

The cell data, which is now part of a string, disappears. I don't
understand why this happens. I've already retrieved the value and
added it to the string so why would it disappear from the string? (I
understand the cell data isn't available once I hide the column) Is
the value of the cell not actually used? ie is a pointer inserted in
the string instead and when I hide the column the pointers become
invalid? I know that doesn't make sense but I've ran out of ideas. I
know it's something I'm missing, it always is ;)

Here is the code
----
Sub RowDataBound(ByVal sender As Object, ByVal e As
GridViewRowEventArgs)


Dim Id As Long

If e.Row.RowType = DataControlRowType.DataRow Then
MessageId = Convert.ToInt32(e.Row.Cells(0).Text)
e.Row.Attributes.Add("onClick", "ShowDetail('" +
Id.ToString() + "')")

' both above and below work if I don't hide column 0
'e.Row.Attributes.Add("onClick", "ShowDetail('" + e.Row.Cells(0).Text
+ "')")
End If

End Sub

---

Any suggestions are very welcome.

tia

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top