You'll need to create a custom method that you can use in your transformations. This can be any class with static methods in your project. Something like this will work
public class BookingEventMethods
{
public static int GetAttendeeCount(object BookingEventNodeID)
object qResult = null;
using(SqlCommand cmd = new SqlCommand("Select Count(AttendeeID) as NumAttendees from Events_Attendee WHERE AttendeeEventNodeID = @NodeID",GetYourConnectionString())
{
cmd.Parameters.AddWithValue("NodeID",BookingEventNodeID);
qResult = cmd.ExecuteScalar();
}
return ValidationHelper.GetInteger(qResult,0);
}
Then you can do something like this in your transformation:
Remaining Capacity: <%# ((int)Eval("EventCapacity") - BookingEventMethods.GetAttendeeCount(Eval("NodeID"))).ToString() %>