views:

496

answers:

1

In one of the rows of a details view control I want to be able to chose what control is to be rendered on edit mode. Basically I have to render a checkbox in one situation, while in another I have to render a text box. Other rows are How can I achieve this, I am a beginner so links and code snippets would be very helpful?

+1  A: 

You can hook into the dataviews Item databound event and then add a control dynamically at runtime to the row.

one thing to be careful of with this method is to make sure that the item type is either an item or an alternate item, but not a header or footer item.

Its been a while since I did this (I've been doing winforms for a year).

I remember it being something like

protected void OnDataViewItemDataBound(object sender, DataViewItemBoundEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item
        || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        TextBox txt = new TextBox();
        txt.DataBindings.Add() // add a databinding here

        e.Item.Controls.Add(txt);
    }
}
Peter