DataRepeaterItemValueEventArgs Constructor
Initializes a new instance of the DataRepeaterItemValueEventArgs class.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
'Declaration
Public Sub New ( _
itemIndex As Integer, _
ctl As Control, _
propertyName As String, _
value As Object _
)
'Usage
Dim itemIndex As Integer
Dim ctl As Control
Dim propertyName As String
Dim value As Object
Dim instance As New DataRepeaterItemValueEventArgs(itemIndex, _
ctl, propertyName, value)
public DataRepeaterItemValueEventArgs(
int itemIndex,
Control ctl,
string propertyName,
Object value
)
public:
DataRepeaterItemValueEventArgs(
int itemIndex,
Control^ ctl,
String^ propertyName,
Object^ value
)
public function DataRepeaterItemValueEventArgs(
itemIndex : int,
ctl : Control,
propertyName : String,
value : Object
)
Parameters
itemIndex
Type: System.Int32The index of the DataRepeaterItem that contains the control that is raising the event.
ctl
Type: System.Windows.Forms.ControlThe child control that is raising the event.
propertyName
Type: System.StringThe property of the control that has changed or that needs data.
value
Type: System.ObjectThe property value that has changed.
Remarks
In virtual mode, use the ItemValueNeeded event to populate the child controls of the ItemTemplate with values from your data store when a DataRepeaterItem is displayed or when a new item is added.
Use the ItemValuePushed event to save changes to the child control values to your data store.
When the VirtualMode property is set to False, these events are not raised.
Examples
The following example demonstrates how to handle the ItemValueNeeded event. It assumes that you have a DataRepeater control named DataRepeater1 that has its VirtualMode property set to True. The code will resemble the following example, which is for a data source named Employees.
Private Sub DataRepeater1_ItemValueNeeded(ByVal sender As Object, _
ByVal e As _
Microsoft.VisualBasic.PowerPacks.DataRepeaterItemValueEventArgs) _
Handles DataRepeater1.ItemValueNeeded
If e.ItemIndex < Employees.Count Then
Select Case e.Control.Name
Case "txtFirstName"
e.Value = Employees.Item(e.ItemIndex + 1).firstName
Case "txtLastName"
e.Value = Employees.Item(e.ItemIndex + 1).lastName
End Select
End If
End Sub
private void dataRepeater1_ItemValueNeeded(object sender, Microsoft.VisualBasic.PowerPacks.DataRepeaterItemValueEventArgs e)
{
if (e.ItemIndex < Employees.Count)
{
switch (e.Control.Name)
{
case "txtFirstName":
e.Value = Employees[e.ItemIndex + 1].firstName;
break;
case "txtLastName":
e.Value = Employees[e.ItemIndex + 1].lastName;
break;
}
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
DataRepeaterItemValueEventArgs Class
DataRepeaterItemValueEventArgs Members
Microsoft.VisualBasic.PowerPacks Namespace