Quick ItemDataBound (datagid cell hiding) help please

Discussion in 'ASP .Net' started by simon, Mar 1, 2007.

  1. simon

    simon Guest

    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.
     
    simon, Mar 1, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KK
    Replies:
    2
    Views:
    646
    Big Brian
    Oct 14, 2003
  2. JKop
    Replies:
    11
    Views:
    915
  3. richard

    hiding table cell border

    richard, Jul 12, 2008, in forum: HTML
    Replies:
    3
    Views:
    889
    richard
    Jul 14, 2008
  4. gane
    Replies:
    0
    Views:
    162
  5. Ste
    Replies:
    41
    Views:
    831
    Thomas 'PointedEars' Lahn
    Aug 1, 2007
Loading...

Share This Page