I have a simple one GridView; something like this for a regular line Itemor AlternatingItem:
+----+-------------+----------+
| ID | Description | Value |
+====+=============+==========+
| 01 | Some text | 0.082 |
+----+-------------+----------+
| 02 | Some text | Yes |
+----+-------------+----------+
| 02 | Some text | 9/4/2009 |
+----+-------------+----------+
When the user selects Change row in GridView, only the "Value" column should become editable. I want to somehow DataItemvisualize a control based on the property of this line (in my case, either regular TextBoxfor decimal values, a DropDownListfor logical "Yes / No", or something else complicated, like a TextBoxwith some calendar control) to edit this values based on its type.
So, for starters, an object containing the above information has a property DataFormatthat has a value that I need to determine which control to display. I have a user control ITemplate. His method InstantiateIn()looks like this:
Public Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn
Select Case Me.ItemType
Case UDFTemplate.Value
Dim valueLabel As New Label()
AddHandler valueLabel.DataBinding, AddressOf ControlDataBinding
container.Controls.Add(valueLabel)
Case UDFTemplate.EditValue
' I don't always want a text box... I want to decide what to create here.
Dim editBox As New TextBox()
editBox.Columns = 15
AddHandler editBox.DataBinding, AddressOf ControlDataBinding
container.Controls.Add(editBox)
End Select
End Sub
My goal is to somehow get to the property DataItemfor GridViewRowwhich I am participating in to decide what type of control will be created in the method InstantiateIn().
Is it possible? I thought I would do it in such a way as to keep it clean and all in one place.
, ! : ItemTemplate , , RowDataBound GridView? , , , . , GridViewRow container, Parent NamingContainer GridViewRow, Nothing, .
- CSS DataControlFieldCell GridView RowCreated, InstantiateIn , , . , , "", , DataItem Nothing, RowCreated "Object not set..." bologna.
... - -?