Can a (windows) datagrid column contain different types of control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MarkDu

    #1

    Can a (windows) datagrid column contain different types of control

    I want to have a datagrid, say 10 rows, and in one of the columns I want 7 of
    the rows to have plain text, and the other 3 rows to have a combobox (or
    linkbutton, etc). Is this even possible?

    I have been reading various articles about how to derive a
    DataGridTextBox Column to put a combobox in the cell, and it's not working too
    well for me. Even if it does sort of work, the combobox is only visible if
    I'm editing the cell. But I want it to stay visible all the time. I'm not
    really going to be "editing" anything with the datagrid, but I'll just be
    responding to events when you change the combobox or click on a link in the
    cell. How do I do this? Thanks.
  • Andreas Knudsen

    #2
    RE: Can a (windows) datagrid column contain different types of control

    Use a template column , add combobox to it,

    and bind the control in an ItemDataBound Eventhandler method

    which handles DataGrid1.ItemD ataBound

    DataGrid1_ItemD ataBound(object sender,
    System.Web.UI.W ebControls.Data GridItemEventAr gs e)
    {
    if(e.Item.ItemT ype.Equals( ListItemType.It em)
    || e.Item.ItemType .Equals(ListIte mType.Alternati ngItem))
    {
    ComboBox cbox = e.Item.FindCont rol("idOfComboB oxInDataGridTem plateColumn")
    as ComboBox

    // Bind Combobox here

    }

    }

    "MarkDu" wrote:
    [color=blue]
    > I want to have a datagrid, say 10 rows, and in one of the columns I want 7 of
    > the rows to have plain text, and the other 3 rows to have a combobox (or
    > linkbutton, etc). Is this even possible?
    >
    > I have been reading various articles about how to derive a
    > DataGridTextBox Column to put a combobox in the cell, and it's not working too
    > well for me. Even if it does sort of work, the combobox is only visible if
    > I'm editing the cell. But I want it to stay visible all the time. I'm not
    > really going to be "editing" anything with the datagrid, but I'll just be
    > responding to events when you change the combobox or click on a link in the
    > cell. How do I do this? Thanks.[/color]

    Comment

    • MarkDu

      #3
      RE: Can a (windows) datagrid column contain different types of con

      Andreas, that sounds like a web datagrid. In a web datagrid, I think it
      would be doable. But can I do it in a windows datagrid?

      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Can a (windows) datagrid column contain different types of control

        Mark,

        Have a look at our website and than this link, there is as well another
        implementation. Know that in the Net 2.0 datagridview what the combobox and
        other controls are standard implemented.



        I hope this helps,

        Cor


        Comment

        Working...