By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,173 Members | 1,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,173 IT Pros & Developers. It's quick & easy.

Quick ItemDataBound (datagid cell hiding) help please

P: n/a
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

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 +
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.

Mar 1 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.