How Move children from one TableCell to Another??

Discussion in 'ASP .Net Datagrid Control' started by Arthur Dent, Jun 30, 2005.

  1. Arthur Dent

    Arthur Dent Guest

    Heres the deal... i have a datagrid which displays products in a category.
    Any category has its own set of columns which show up in the grid, so it is
    defined as AutoGenerateColumns=True

    There is a static column which has a textbox and button for entering a qty
    and
    adding the item to your shopping cart.

    The client INSISTS that the qty/order controls be on the right of the grid,
    which
    means i need to somehow either put the static column at the end of the grid,
    or fake it.

    I understand the static columns CANT go at the end. So what i want to do is
    return one
    extra column at the end of my dynamic columns (easy) and then MOVE the
    qty/order
    controls from the static column cell into the last dynamic column cell, and
    hide the static.
    SOUNDS easy, but i cant get it to work.... heres my code:

    Private Sub grdProds_ItemCreated(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    grdProds.ItemCreated
    Dim i As DataGridItem = e.Item
    i.Cells(0).Visible = False '// tblOrder HOST (qty textbox and order
    button)
    i.Cells(1).Visible = False '// ID
    i.Cells(2).Visible = False '// PRICE

    Select Case i.ItemType
    Case ListItemType.Item, ListItemType.AlternatingItem
    Dim tbl As Control = i.FindControl("tblOrder")
    tbl.Parent.Controls.Remove(tbl)
    i.Cells(i.Cells.Count - 1).Controls.Add(tbl)
    End Select
    End Sub

    How can i move the tblOrder control (HTMLTable) from one cell to another??
    Thanks in advance,
    - Arthur Dent.
     
    Arthur Dent, Jun 30, 2005
    #1
    1. Advertising

  2. Arthur Dent

    Arthur Dent Guest

    I sort of got around this. I moved the code from ItemCreated to
    ItemDatabound.
    Then it wouldnt rerun though on postbacks. So then i moved it to
    grdProds_PreRender.
    Only problem now is that the postbacks dont work. I think because the
    clientids are all messed up now??



    "Arthur Dent" <> wrote in message
    news:...
    > Heres the deal... i have a datagrid which displays products in a category.
    > Any category has its own set of columns which show up in the grid, so it
    > is
    > defined as AutoGenerateColumns=True
    >
    > There is a static column which has a textbox and button for entering a qty
    > and
    > adding the item to your shopping cart.
    >
    > The client INSISTS that the qty/order controls be on the right of the
    > grid, which
    > means i need to somehow either put the static column at the end of the
    > grid, or fake it.
    >
    > I understand the static columns CANT go at the end. So what i want to do
    > is return one
    > extra column at the end of my dynamic columns (easy) and then MOVE the
    > qty/order
    > controls from the static column cell into the last dynamic column cell,
    > and hide the static.
    > SOUNDS easy, but i cant get it to work.... heres my code:
    >
    > Private Sub grdProds_ItemCreated(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    > grdProds.ItemCreated
    > Dim i As DataGridItem = e.Item
    > i.Cells(0).Visible = False '// tblOrder HOST (qty textbox and order
    > button)
    > i.Cells(1).Visible = False '// ID
    > i.Cells(2).Visible = False '// PRICE
    >
    > Select Case i.ItemType
    > Case ListItemType.Item, ListItemType.AlternatingItem
    > Dim tbl As Control = i.FindControl("tblOrder")
    > tbl.Parent.Controls.Remove(tbl)
    > i.Cells(i.Cells.Count - 1).Controls.Add(tbl)
    > End Select
    > End Sub
    >
    > How can i move the tblOrder control (HTMLTable) from one cell to another??
    > Thanks in advance,
    > - Arthur Dent.
    >
     
    Arthur Dent, Jun 30, 2005
    #2
    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. Brian K. Williams

    TableCell oTableCell = new TableCell(); noWrap?

    Brian K. Williams, Apr 30, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,598
    Brian K. Williams
    Apr 30, 2004
  2. Arthur Dent
    Replies:
    1
    Views:
    467
    Arthur Dent
    Jun 30, 2005
  3. Replies:
    1
    Views:
    261
  4. Eduardo78
    Replies:
    0
    Views:
    279
    Eduardo78
    Nov 3, 2005
  5. Andrew Tomazos
    Replies:
    2
    Views:
    703
    Nobody
    Dec 12, 2011
Loading...

Share This Page