Share via


DataRepeater.ItemValueNeeded Event

Occurs when the VirtualMode property is set to True and a new value for a child control of a DataRepeaterItem is needed.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

'Declaration
Public Event ItemValueNeeded As DataRepeaterItemValueEventHandler
public event DataRepeaterItemValueEventHandler ItemValueNeeded
public:
 event DataRepeaterItemValueEventHandler^ ItemValueNeeded {
    void add (DataRepeaterItemValueEventHandler^ value);
    void remove (DataRepeaterItemValueEventHandler^ value);
}
member ItemValueNeeded : IEvent<DataRepeaterItemValueEventHandler,
    DataRepeaterItemValueEventArgs>
JScript does not support events.

Remarks

In virtual mode, use this event to populate the child controls with values from your data store when a DataRepeaterItem is displayed or when a new item is added.

When the VirtualMode property is set to False, this event is not raised.

For more information about how to handle events, see Consuming Events.

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, and that you have a data store 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

See Also

Reference

DataRepeater Class

Microsoft.VisualBasic.PowerPacks Namespace

ItemValuePushed

NewItemNeeded

Other Resources

Introduction to the DataRepeater Control (Visual Studio)

Virtual Mode in the DataRepeater Control (Visual Studio)