Quick ItemDataBound (datagid cell hiding) help please

S

simon

hello,
I was hoping someone could help me with an issue (using vb & .net 2.0)
I have a datagrid and the first column shown i have an asp:textbox
that i basically want to "group by" an ID and only want to show the
textbox for unique values.

the grid has a seriesID bound and invisible in the grid and i'm doing
an ItemDataBound function call on the grid, i spin thru the rows from
the dataset, if the first current row's ID doesn't match the previous,
i want to show the textbox. if it does match i want to hide the
textbox.

in the code behind, i have a global variable defined:
Public prevSeriesID As Int64
(Int64 because the field in the db is BigInt).
that is initialized to -1 in the !postback in page_load

this is my ItemDataBound function:

Sub ItemDataBoundEventHandler(ByVal sender As Object, ByVal e
As DataGridItemEventArgs)

If e.Item.ItemType <> ListItemType.Header And
e.Item.ItemType <> ListItemType.Footer Then

Dim currSeriesID =
Convert.ToInt64(DataBinder.Eval(e.Item.DataItem, "SeriesID"))
lblMessage.Text = lblMessage.Text + _
" curr = " + Str(currSeriesID) + " prev = " +
Str(prevSeriesID) + "<br>"


If currSeriesID = prevSeriesID Then
lblMessage.Text = lblMessage.Text +
"***MATCH***<br>"
e.Item.BackColor = System.Drawing.Color.Yellow
End If
prevSeriesID = currSeriesID

End If
End Sub


the lblMessage is just for my debugging and is showing that the logic
is working correctly. also the changing of the background color to
yellow is working correctly, so the proper rows are being "affected"

I tried
e.Item.Visible = False, but that didn't do anything
e.Item.Cell.Visible = False, that didn't work either
e.Item.cells[0].RowSpan = 2, but that is an invalid line

can you tell me how to make that row cell containing the textbox
invisible or the correct syntax to alter the rowspan?

thank you very much for your reply.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top